diff --git a/bundleplugin/src/main/java/aQute/libg/asn1/BER.java b/bundleplugin/src/main/java/aQute/libg/asn1/BER.java
index 4416dd4..bde15aa 100644
--- a/bundleplugin/src/main/java/aQute/libg/asn1/BER.java
+++ b/bundleplugin/src/main/java/aQute/libg/asn1/BER.java
@@ -5,468 +5,463 @@
 import java.util.*;
 
 public class BER implements Types {
-    DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss\\Z");
-    
-    final DataInputStream xin;
-    long                  position;
+	DateFormat				df	= new SimpleDateFormat("yyyyMMddHHmmss\\Z");
 
-    public BER(InputStream in) {
-        this.xin = new DataInputStream(in);
-    }
+	final DataInputStream	xin;
+	long					position;
 
-    public void dump(PrintStream out) throws Exception {
-        int type = readByte();
-        long length = readLength();
-        if (type == -1 || length == -1)
-            throw new EOFException("Empty file");
-        dump(out, type, length, "");
-    }
+	public BER(InputStream in) {
+		this.xin = new DataInputStream(in);
+	}
 
-    void dump(PrintStream out, int type, long length, String indent)
-            throws Exception {
-        int clss = type >> 6;
-        int nmbr = type & 0x1F;
-        boolean cnst = (type & 0x20) != 0;
+	public void dump(PrintStream out) throws Exception {
+		int type = readByte();
+		long length = readLength();
+		if (type == -1 || length == -1)
+			throw new EOFException("Empty file");
+		dump(out, type, length, "");
+	}
 
-        String tag = "[" + nmbr + "]";
-        if (clss == 0)
-            tag = TAGS[nmbr];
+	void dump(PrintStream out, int type, long length, String indent) throws Exception {
+		int clss = type >> 6;
+		int nmbr = type & 0x1F;
+		boolean cnst = (type & 0x20) != 0;
 
-        if (cnst) {
-            System.err.printf("%5d %s %s %s%n", length, indent, CLASSES[clss],
-                    tag);
-            while (length > 1) {
-                long atStart = getPosition();
-                int t2 = read();
-                long l2 = readLength();
-                dump(out, t2, l2, indent + "  ");
-                length -= getPosition() - atStart;
-            }
-        } else {
-            assert length < Integer.MAX_VALUE;
-            assert length >= 0;
-            byte[] data = new byte[(int) length];
-            readFully(data);
-            String summary;
+		String tag = "[" + nmbr + "]";
+		if (clss == 0)
+			tag = TAGS[nmbr];
 
-            switch (nmbr) {
-            case BOOLEAN:
-                assert length == 1;
-                summary = data[0] != 0 ? "true" : "false";
-                break;
+		if (cnst) {
+			System.err.printf("%5d %s %s %s%n", length, indent, CLASSES[clss], tag);
+			while (length > 1) {
+				long atStart = getPosition();
+				int t2 = read();
+				long l2 = readLength();
+				dump(out, t2, l2, indent + "  ");
+				length -= getPosition() - atStart;
+			}
+		} else {
+			assert length < Integer.MAX_VALUE;
+			assert length >= 0;
+			byte[] data = new byte[(int) length];
+			readFully(data);
+			String summary;
 
-            case INTEGER:
-                long n = toLong(data);
-                summary = n + "";
-                break;
+			switch (nmbr) {
+				case BOOLEAN :
+					assert length == 1;
+					summary = data[0] != 0 ? "true" : "false";
+					break;
 
-            case UTF8_STRING:
-            case IA5STRING:
-            case VISIBLE_STRING:
-            case UNIVERSAL_STRING:
-            case PRINTABLE_STRING:
-            case UTCTIME:
-                summary = new String(data, "UTF-8");
-                break;
+				case INTEGER :
+					long n = toLong(data);
+					summary = n + "";
+					break;
 
-            case OBJECT_IDENTIFIER:
-                summary = readOID(data);
-                break;
+				case UTF8_STRING :
+				case IA5STRING :
+				case VISIBLE_STRING :
+				case UNIVERSAL_STRING :
+				case PRINTABLE_STRING :
+				case UTCTIME :
+					summary = new String(data, "UTF-8");
+					break;
 
-            case GENERALIZED_TIME:
-            case GRAPHIC_STRING:
-            case GENERAL_STRING:
-            case CHARACTER_STRING:
+				case OBJECT_IDENTIFIER :
+					summary = readOID(data);
+					break;
 
-            case REAL:
-            case EOC:
-            case BIT_STRING:
-            case OCTET_STRING:
-            case NULL:
-            case OBJECT_DESCRIPTOR:
-            case EXTERNAL:
-            case ENUMERATED:
-            case EMBEDDED_PDV:
-            case RELATIVE_OID:
-            case NUMERIC_STRING:
-            case T61_STRING:
-            case VIDEOTEX_STRING:
-            case BMP_STRING:
-            default:
-                StringBuilder sb = new StringBuilder();
-                for (int i = 0; i < 10 && i < data.length; i++) {
-                    sb.append(Integer.toHexString(data[i]));
-                }
-                if (data.length > 10) {
-                    sb.append("...");
-                }
-                summary = sb.toString();
-                break;
-            }
-            out.printf("%5d %s %s %s %s\n", length, indent, CLASSES[clss], tag,
-                    summary);
-        }
-    }
+				case GENERALIZED_TIME :
+				case GRAPHIC_STRING :
+				case GENERAL_STRING :
+				case CHARACTER_STRING :
 
-    long toLong(byte[] data) {
-        if (data[0] < 0) {
-            for (int i = 0; i < data.length; i++)
-                data[i] = (byte) (0xFF ^ data[i]);
+				case REAL :
+				case EOC :
+				case BIT_STRING :
+				case OCTET_STRING :
+				case NULL :
+				case OBJECT_DESCRIPTOR :
+				case EXTERNAL :
+				case ENUMERATED :
+				case EMBEDDED_PDV :
+				case RELATIVE_OID :
+				case NUMERIC_STRING :
+				case T61_STRING :
+				case VIDEOTEX_STRING :
+				case BMP_STRING :
+				default :
+					StringBuilder sb = new StringBuilder();
+					for (int i = 0; i < 10 && i < data.length; i++) {
+						sb.append(Integer.toHexString(data[i]));
+					}
+					if (data.length > 10) {
+						sb.append("...");
+					}
+					summary = sb.toString();
+					break;
+			}
+			out.printf("%5d %s %s %s %s\n", length, indent, CLASSES[clss], tag, summary);
+		}
+	}
 
-            return -(toLong(data) + 1);
-        }
-        long n = 0;
-        for (int i = 0; i < data.length; i++) {
-            n = n * 256 + data[i];
-        }
-        return n;
-    }
+	long toLong(byte[] data) {
+		if (data[0] < 0) {
+			for (int i = 0; i < data.length; i++)
+				data[i] = (byte) (0xFF ^ data[i]);
 
-    /**
-     * 8.1.3.3 For the definite form, the length octets shall consist of one or
-     * more octets, and shall represent the number of octets in the contents
-     * octets using either the short form (see 8.1.3.4) or the long form (see
-     * 8.1.3.5) as a sender's option. NOTE – The short form can only be used if
-     * the number of octets in the contents octets is less than or equal to 127.
-     * 8.1.3.4 In the short form, the length octets shall consist of a single
-     * octet in which bit 8 is zero and bits 7 to 1 encode the number of octets
-     * in the contents octets (which may be zero), as an unsigned binary integer
-     * with bit 7 as the most significant bit. EXAMPLE L = 38 can be encoded as
-     * 001001102 8.1.3.5 In the long form, the length octets shall consist of an
-     * initial octet and one or more subsequent octets. The initial octet shall
-     * be encoded as follows: a) bit 8 shall be one; b) bits 7 to 1 shall encode
-     * the number of subsequent octets in the length octets, as an unsigned
-     * binary integer with bit 7 as the most significant bit; c) the value
-     * 111111112 shall not be used. ISO/IEC 8825-1:2003 (E) NOTE 1 – This
-     * restriction is introduced for possible future extension. Bits 8 to 1 of
-     * the first subsequent octet, followed by bits 8 to 1 of the second
-     * subsequent octet, followed in turn by bits 8 to 1 of each further octet
-     * up to and including the last subsequent octet, shall be the encoding of
-     * an unsigned binary integer equal to the number of octets in the contents
-     * octets, with bit 8 of the first subsequent octet as the most significant
-     * bit. EXAMPLE L = 201 can be encoded as: 100000012 110010012 NOTE 2 – In
-     * the long form, it is a sender's option whether to use more length octets
-     * than the minimum necessary. 8.1.3.6 For the indefinite form, the length
-     * octets indicate that the contents octets are terminated by
-     * end-of-contents octets (see 8.1.5), and shall consist of a single octet.
-     * 8.1.3.6.1 The single octet shall have bit 8 set to one, and bits 7 to 1
-     * set to zero. 8.1.3.6.2 If this form of length is used, then
-     * end-of-contents octets (see 8.1.5) shall be present in the encoding
-     * following the contents octets. 8.1.4 Contents octets The contents octets
-     * shall consist of zero, one or more octets, and shall encode the data
-     * value as specified in subsequent clauses. NOTE – The contents octets
-     * depend on the type of the data value; subsequent clauses follow the same
-     * sequence as the definition of types in ASN.1. 8.1.5 End-of-contents
-     * octets The end-of-contents octets shall be present if the length is
-     * encoded as specified in 8.1.3.6, otherwise they shall not be present. The
-     * end-of-contents octets shall consist of two zero octets. NOTE – The
-     * end-of-contents octets can be considered as the encoding of a value whose
-     * tag is universal class, whose form is primitive, whose number of the tag
-     * is zero, and whose contents are absent, thus:
-     * 
-     * End-of-contents Length Contents 0016 0016 Absent
-     * 
-     * @return
-     */
-    private long readLength() throws IOException {
-        long n = readByte();
-        if (n > 0) {
-            // short form
-            return n;
-        }
+			return -(toLong(data) + 1);
+		}
+		long n = 0;
+		for (int i = 0; i < data.length; i++) {
+			n = n * 256 + data[i];
+		}
+		return n;
+	}
+
+	/**
+	 * 8.1.3.3 For the definite form, the length octets shall consist of one or
+	 * more octets, and shall represent the number of octets in the contents
+	 * octets using either the short form (see 8.1.3.4) or the long form (see
+	 * 8.1.3.5) as a sender's option. NOTE – The short form can only be used if
+	 * the number of octets in the contents octets is less than or equal to 127.
+	 * 8.1.3.4 In the short form, the length octets shall consist of a single
+	 * octet in which bit 8 is zero and bits 7 to 1 encode the number of octets
+	 * in the contents octets (which may be zero), as an unsigned binary integer
+	 * with bit 7 as the most significant bit. EXAMPLE L = 38 can be encoded as
+	 * 001001102 8.1.3.5 In the long form, the length octets shall consist of an
+	 * initial octet and one or more subsequent octets. The initial octet shall
+	 * be encoded as follows: a) bit 8 shall be one; b) bits 7 to 1 shall encode
+	 * the number of subsequent octets in the length octets, as an unsigned
+	 * binary integer with bit 7 as the most significant bit; c) the value
+	 * 111111112 shall not be used. ISO/IEC 8825-1:2003 (E) NOTE 1 – This
+	 * restriction is introduced for possible future extension. Bits 8 to 1 of
+	 * the first subsequent octet, followed by bits 8 to 1 of the second
+	 * subsequent octet, followed in turn by bits 8 to 1 of each further octet
+	 * up to and including the last subsequent octet, shall be the encoding of
+	 * an unsigned binary integer equal to the number of octets in the contents
+	 * octets, with bit 8 of the first subsequent octet as the most significant
+	 * bit. EXAMPLE L = 201 can be encoded as: 100000012 110010012 NOTE 2 – In
+	 * the long form, it is a sender's option whether to use more length octets
+	 * than the minimum necessary. 8.1.3.6 For the indefinite form, the length
+	 * octets indicate that the contents octets are terminated by
+	 * end-of-contents octets (see 8.1.5), and shall consist of a single octet.
+	 * 8.1.3.6.1 The single octet shall have bit 8 set to one, and bits 7 to 1
+	 * set to zero. 8.1.3.6.2 If this form of length is used, then
+	 * end-of-contents octets (see 8.1.5) shall be present in the encoding
+	 * following the contents octets. 8.1.4 Contents octets The contents octets
+	 * shall consist of zero, one or more octets, and shall encode the data
+	 * value as specified in subsequent clauses. NOTE – The contents octets
+	 * depend on the type of the data value; subsequent clauses follow the same
+	 * sequence as the definition of types in ASN.1. 8.1.5 End-of-contents
+	 * octets The end-of-contents octets shall be present if the length is
+	 * encoded as specified in 8.1.3.6, otherwise they shall not be present. The
+	 * end-of-contents octets shall consist of two zero octets. NOTE – The
+	 * end-of-contents octets can be considered as the encoding of a value whose
+	 * tag is universal class, whose form is primitive, whose number of the tag
+	 * is zero, and whose contents are absent, thus: End-of-contents Length
+	 * Contents 0016 0016 Absent
+	 * 
+	 * @return
+	 */
+	private long readLength() throws IOException {
+		long n = readByte();
+		if (n > 0) {
+			// short form
+			return n;
+		}
 		// long form
 		int count = (int) (n & 0x7F);
 		if (count == 0) {
-		    // indefinite form
-		    return 0;
+			// indefinite form
+			return 0;
 		}
 		n = 0;
 		while (count-- > 0) {
-		    n = n * 256 + read();
+			n = n * 256 + read();
 		}
 		return n;
-    }
+	}
 
-    private int readByte() throws IOException {
-        position++;
-        return xin.readByte();
-    }
+	private int readByte() throws IOException {
+		position++;
+		return xin.readByte();
+	}
 
-    private void readFully(byte[] data) throws IOException {
-        position += data.length;
-        xin.readFully(data);
-    }
+	private void readFully(byte[] data) throws IOException {
+		position += data.length;
+		xin.readFully(data);
+	}
 
-    private long getPosition() {
-        return position;
-    }
+	private long getPosition() {
+		return position;
+	}
 
-    private int read() throws IOException {
-        position++;
-        return xin.read();
-    }
+	private int read() throws IOException {
+		position++;
+		return xin.read();
+	}
 
-    String readOID(byte[] data) {
-        StringBuilder sb = new StringBuilder();
-        sb.append((0xFF & data[0]) / 40);
-        sb.append(".");
-        sb.append((0xFF & data[0]) % 40);
+	String readOID(byte[] data) {
+		StringBuilder sb = new StringBuilder();
+		sb.append((0xFF & data[0]) / 40);
+		sb.append(".");
+		sb.append((0xFF & data[0]) % 40);
 
-        int i = 0;
-        while (++i < data.length) {
-            int n = 0;
-            while (data[i] < 0) {
-                n = n * 128 + (0x7F & data[i]);
-                i++;
-            }
-            n = n * 128 + data[i];
-            sb.append(".");
-            sb.append(n);
-        }
+		int i = 0;
+		while (++i < data.length) {
+			int n = 0;
+			while (data[i] < 0) {
+				n = n * 128 + (0x7F & data[i]);
+				i++;
+			}
+			n = n * 128 + data[i];
+			sb.append(".");
+			sb.append(n);
+		}
 
-        return sb.toString();
-    }
+		return sb.toString();
+	}
 
-    int getPayloadLength(PDU pdu) throws Exception {
-        switch (pdu.getTag() & 0x1F) {
-        case EOC:
-            return 1;
+	int getPayloadLength(PDU pdu) throws Exception {
+		switch (pdu.getTag() & 0x1F) {
+			case EOC :
+				return 1;
 
-        case BOOLEAN:
-            return 1;
+			case BOOLEAN :
+				return 1;
 
-        case INTEGER:
-            return size(pdu.getInt());
+			case INTEGER :
+				return size(pdu.getInt());
 
-        case UTF8_STRING:
-            String s = pdu.getString();
-            byte[] encoded = s.getBytes("UTF-8");
-            return encoded.length;
+			case UTF8_STRING :
+				String s = pdu.getString();
+				byte[] encoded = s.getBytes("UTF-8");
+				return encoded.length;
 
-        case IA5STRING:
-        case VISIBLE_STRING:
-        case UNIVERSAL_STRING:
-        case PRINTABLE_STRING:
-        case GENERALIZED_TIME:
-        case GRAPHIC_STRING:
-        case GENERAL_STRING:
-        case CHARACTER_STRING:
-        case UTCTIME:
-        case NUMERIC_STRING: {
-            String str = pdu.getString();
-            encoded = str.getBytes("ASCII");
-            return encoded.length;
-        }
+			case IA5STRING :
+			case VISIBLE_STRING :
+			case UNIVERSAL_STRING :
+			case PRINTABLE_STRING :
+			case GENERALIZED_TIME :
+			case GRAPHIC_STRING :
+			case GENERAL_STRING :
+			case CHARACTER_STRING :
+			case UTCTIME :
+			case NUMERIC_STRING : {
+				String str = pdu.getString();
+				encoded = str.getBytes("ASCII");
+				return encoded.length;
+			}
 
-        case OBJECT_IDENTIFIER:
-        case REAL:
-        case BIT_STRING:
-            return pdu.getBytes().length;
+			case OBJECT_IDENTIFIER :
+			case REAL :
+			case BIT_STRING :
+				return pdu.getBytes().length;
 
-        case OCTET_STRING:
-        case NULL:
-        case OBJECT_DESCRIPTOR:
-        case EXTERNAL:
-        case ENUMERATED:
-        case EMBEDDED_PDV:
-        case RELATIVE_OID:
-        case T61_STRING:
-        case VIDEOTEX_STRING:
-        case BMP_STRING:
-            return pdu.getBytes().length;
+			case OCTET_STRING :
+			case NULL :
+			case OBJECT_DESCRIPTOR :
+			case EXTERNAL :
+			case ENUMERATED :
+			case EMBEDDED_PDV :
+			case RELATIVE_OID :
+			case T61_STRING :
+			case VIDEOTEX_STRING :
+			case BMP_STRING :
+				return pdu.getBytes().length;
 
-        default:
-            throw new IllegalArgumentException("Invalid type: " + pdu);
-        }
-    }
+			default :
+				throw new IllegalArgumentException("Invalid type: " + pdu);
+		}
+	}
 
-    int size(long value) {
-        if (value < 128)
-            return 1;
+	int size(long value) {
+		if (value < 128)
+			return 1;
 
-        if (value <= 0xFF)
-            return 2;
+		if (value <= 0xFF)
+			return 2;
 
-        if (value <= 0xFFFF)
-            return 3;
+		if (value <= 0xFFFF)
+			return 3;
 
-        if (value <= 0xFFFFFF)
-            return 4;
+		if (value <= 0xFFFFFF)
+			return 4;
 
-        if (value <= 0xFFFFFFFF)
-            return 5;
+		if (value <= 0xFFFFFFFF)
+			return 5;
 
-        if (value <= 0xFFFFFFFFFFL)
-            return 6;
+		if (value <= 0xFFFFFFFFFFL)
+			return 6;
 
-        if (value <= 0xFFFFFFFFFFFFL)
-            return 7;
+		if (value <= 0xFFFFFFFFFFFFL)
+			return 7;
 
-        if (value <= 0xFFFFFFFFFFFFFFL)
-            return 8;
+		if (value <= 0xFFFFFFFFFFFFFFL)
+			return 8;
 
-        if (value <= 0xFFFFFFFFFFFFFFFFL)
-            return 9;
+		if (value <= 0xFFFFFFFFFFFFFFFFL)
+			return 9;
 
-        throw new IllegalArgumentException("length too long");
-    }
+		throw new IllegalArgumentException("length too long");
+	}
 
-    public void write(OutputStream out, PDU pdu) throws Exception {
-        byte id = 0;
+	public void write(OutputStream out, PDU pdu) throws Exception {
+		byte id = 0;
 
-        switch (pdu.getClss()) {
-        case UNIVERSAL:
-            id |= 0;
-            break;
-        case APPLICATION:
-            id |= 0x40;
-            break;
-        case CONTEXT:
-            id |= 0x80;
-            break;
-        case PRIVATE:
-            id |= 0xC0;
-            break;
-        }
+		switch (pdu.getClss()) {
+			case UNIVERSAL :
+				id |= 0;
+				break;
+			case APPLICATION :
+				id |= 0x40;
+				break;
+			case CONTEXT :
+				id |= 0x80;
+				break;
+			case PRIVATE :
+				id |= 0xC0;
+				break;
+		}
 
-        if (pdu.isConstructed())
-            id |= 0x20;
+		if (pdu.isConstructed())
+			id |= 0x20;
 
-        int tag = pdu.getTag();
-        if (tag >= 0 && tag < 31) {
-            id |= tag;
-        } else {
-            throw new UnsupportedOperationException("Cant do tags > 30");
-        }
+		int tag = pdu.getTag();
+		if (tag >= 0 && tag < 31) {
+			id |= tag;
+		} else {
+			throw new UnsupportedOperationException("Cant do tags > 30");
+		}
 
-        out.write(id);
+		out.write(id);
 
-        int length = getPayloadLength(pdu);
-        int size = size(length);
-        if (size == 1) {
-            out.write(length);
-        } else {
-            out.write(size);
-            while (--size >= 0) {
-                byte data = (byte) ((length >> (size * 8)) & 0xFF);
-                out.write(data);
-            }
-        }
-        writePayload(out, pdu);
-    }
+		int length = getPayloadLength(pdu);
+		int size = size(length);
+		if (size == 1) {
+			out.write(length);
+		} else {
+			out.write(size);
+			while (--size >= 0) {
+				byte data = (byte) ((length >> (size * 8)) & 0xFF);
+				out.write(data);
+			}
+		}
+		writePayload(out, pdu);
+	}
 
-    void writePayload(OutputStream out, PDU pdu) throws Exception {
-        switch (pdu.getTag()) {
-        case EOC:
-            out.write(0);
-            break;
+	void writePayload(OutputStream out, PDU pdu) throws Exception {
+		switch (pdu.getTag()) {
+			case EOC :
+				out.write(0);
+				break;
 
-        case BOOLEAN:
-            if (pdu.getBoolean())
-                out.write(-1);
-            else
-                out.write(0);
-            break;
+			case BOOLEAN :
+				if (pdu.getBoolean())
+					out.write(-1);
+				else
+					out.write(0);
+				break;
 
-        case ENUMERATED:
-        case INTEGER: {
-            long value = pdu.getInt();
-            int size = size(value);
-            for (int i = size; i >= 0; i--) {
-                byte b = (byte) ((value >> (i * 8)) & 0xFF);
-                out.write(b);
-            }
-        }
+			case ENUMERATED :
+			case INTEGER : {
+				long value = pdu.getInt();
+				int size = size(value);
+				for (int i = size; i >= 0; i--) {
+					byte b = (byte) ((value >> (i * 8)) & 0xFF);
+					out.write(b);
+				}
+			}
 
-        case BIT_STRING: {
-            byte bytes[] = pdu.getBytes();
-            int unused = bytes[0];
-            assert unused <= 7;
-            int[] mask = { 0xFF, 0x7F, 0x3F, 0x1F, 0xF, 0x7, 0x3, 0x1 };
-            bytes[bytes.length - 1] &= (byte) mask[unused];
-            out.write(bytes);
-            break;
-        }
+			case BIT_STRING : {
+				byte bytes[] = pdu.getBytes();
+				int unused = bytes[0];
+				assert unused <= 7;
+				int[] mask = {
+						0xFF, 0x7F, 0x3F, 0x1F, 0xF, 0x7, 0x3, 0x1
+				};
+				bytes[bytes.length - 1] &= (byte) mask[unused];
+				out.write(bytes);
+				break;
+			}
 
-        case RELATIVE_OID:
-        case OBJECT_IDENTIFIER: {
-            int[] oid = pdu.getOID();
-            assert oid.length > 2;
-            assert oid[0] < 4;
-            assert oid[1] < 40;
-            byte top = (byte) (oid[0] * 40 + oid[1]);
-            out.write(top);
-            for (int i = 2; i < oid.length; i++) {
-                putOid(out,oid[i]);
-            }
-            break;
-        }
+			case RELATIVE_OID :
+			case OBJECT_IDENTIFIER : {
+				int[] oid = pdu.getOID();
+				assert oid.length > 2;
+				assert oid[0] < 4;
+				assert oid[1] < 40;
+				byte top = (byte) (oid[0] * 40 + oid[1]);
+				out.write(top);
+				for (int i = 2; i < oid.length; i++) {
+					putOid(out, oid[i]);
+				}
+				break;
+			}
 
-        case OCTET_STRING: {
-            byte bytes[] = pdu.getBytes();
-            out.write(bytes);
-            break;
-        }
+			case OCTET_STRING : {
+				byte bytes[] = pdu.getBytes();
+				out.write(bytes);
+				break;
+			}
 
-        case NULL:
-            break;
+			case NULL :
+				break;
 
-        case BMP_STRING:
-        case GRAPHIC_STRING:
-        case VISIBLE_STRING:
-        case GENERAL_STRING:
-        case UNIVERSAL_STRING:
-        case CHARACTER_STRING:
-        case NUMERIC_STRING:
-        case PRINTABLE_STRING:
-        case VIDEOTEX_STRING:
-        case T61_STRING:
-        case REAL:
-        case EMBEDDED_PDV:
-        case EXTERNAL:
-            throw new UnsupportedEncodingException("dont know real, embedded PDV or external");
-            
-        case UTF8_STRING: {
-            String s = pdu.getString();
-            byte [] data = s.getBytes("UTF-8");
-            out.write(data);
-            break;
-        }
-        
-        case OBJECT_DESCRIPTOR:
-        case IA5STRING:
-            String s = pdu.getString();
-            byte [] data = s.getBytes("ASCII");
-            out.write(data);
-            break;
-            
-            
-        case SEQUENCE:
-        case SET: {
-            PDU pdus[] = pdu.getChildren();
-            for ( PDU p : pdus ) {
-                write(out, p);
-            }
-        }
-            
-        
-        case UTCTIME:
-        case GENERALIZED_TIME:
-            Date date = pdu.getDate();
-            String ss= df.format(date);
-            byte d[] = ss.getBytes("ASCII");
-            out.write(d);
-            break;
-            
-        }
-    }
-    
+			case BMP_STRING :
+			case GRAPHIC_STRING :
+			case VISIBLE_STRING :
+			case GENERAL_STRING :
+			case UNIVERSAL_STRING :
+			case CHARACTER_STRING :
+			case NUMERIC_STRING :
+			case PRINTABLE_STRING :
+			case VIDEOTEX_STRING :
+			case T61_STRING :
+			case REAL :
+			case EMBEDDED_PDV :
+			case EXTERNAL :
+				throw new UnsupportedEncodingException("dont know real, embedded PDV or external");
 
-    private void putOid(OutputStream out, int i) throws IOException {
-        if (i > 127) {
-            putOid(out, i >> 7);
-            out.write(0x80 + (i & 0x7F));
-        } else
-            out.write(i & 0x7F);
-    }
+			case UTF8_STRING : {
+				String s = pdu.getString();
+				byte[] data = s.getBytes("UTF-8");
+				out.write(data);
+				break;
+			}
+
+			case OBJECT_DESCRIPTOR :
+			case IA5STRING :
+				String s = pdu.getString();
+				byte[] data = s.getBytes("ASCII");
+				out.write(data);
+				break;
+
+			case SEQUENCE :
+			case SET : {
+				PDU pdus[] = pdu.getChildren();
+				for (PDU p : pdus) {
+					write(out, p);
+				}
+			}
+
+			case UTCTIME :
+			case GENERALIZED_TIME :
+				Date date = pdu.getDate();
+				String ss = df.format(date);
+				byte d[] = ss.getBytes("ASCII");
+				out.write(d);
+				break;
+
+		}
+	}
+
+	private void putOid(OutputStream out, int i) throws IOException {
+		if (i > 127) {
+			putOid(out, i >> 7);
+			out.write(0x80 + (i & 0x7F));
+		} else
+			out.write(i & 0x7F);
+	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/asn1/PDU.java b/bundleplugin/src/main/java/aQute/libg/asn1/PDU.java
index 033928c..2fb29fb 100644
--- a/bundleplugin/src/main/java/aQute/libg/asn1/PDU.java
+++ b/bundleplugin/src/main/java/aQute/libg/asn1/PDU.java
@@ -3,112 +3,109 @@
 import java.util.*;
 
 public class PDU implements Types, Iterable<PDU> {
-    final int identifier;
-    final Object  payload;
-    byte data[] = new byte[100];
+	final int		identifier;
+	final Object	payload;
+	byte			data[]	= new byte[100];
 
+	public PDU(int id, Object payload) {
+		identifier = id;
+		this.payload = payload;
+	}
 
-    public PDU(int id, Object payload) {
-        identifier = id;
-        this.payload = payload;
-    }
+	public PDU(Date payload) {
+		identifier = UTCTIME;
+		this.payload = payload;
+	}
 
-    public PDU(Date payload) {
-        identifier = UTCTIME;
-        this.payload = payload;
-    }
+	public PDU(int n) {
+		this(UNIVERSAL + INTEGER, n);
+	}
 
-    public PDU(int n) {
-        this(UNIVERSAL+INTEGER, n);
-    }
+	public PDU(boolean value) {
+		this(UNIVERSAL + BOOLEAN, value);
+	}
 
-    public PDU(boolean value) {
-        this(UNIVERSAL+BOOLEAN, value);
-    }
+	public PDU(String s) throws Exception {
+		this(UNIVERSAL + IA5STRING, s);
+	}
 
-    public PDU(String s) throws Exception {
-        this(UNIVERSAL+IA5STRING, s);
-    }
-    
-    public PDU(byte[] data) {
-        this(UNIVERSAL+OCTET_STRING, data);
-    }
-    
-    public PDU(BitSet bits) {
-        this(UNIVERSAL+BIT_STRING, bits);
-    }
+	public PDU(byte[] data) {
+		this(UNIVERSAL + OCTET_STRING, data);
+	}
 
-    public PDU(int top, int l1, int... remainder) {
-        identifier = UNIVERSAL+OBJECT_IDENTIFIER;
-        int[] ids = new int[remainder.length + 2];
-        ids[0] = top;
-        ids[1] = l1;
-        System.arraycopy(remainder, 0, ids, 2, remainder.length);
-        payload = ids;
-    }
+	public PDU(BitSet bits) {
+		this(UNIVERSAL + BIT_STRING, bits);
+	}
 
-    public PDU(int tag, PDU... set) {
-        this(tag,(Object)set);
-    }
+	public PDU(int top, int l1, int... remainder) {
+		identifier = UNIVERSAL + OBJECT_IDENTIFIER;
+		int[] ids = new int[remainder.length + 2];
+		ids[0] = top;
+		ids[1] = l1;
+		System.arraycopy(remainder, 0, ids, 2, remainder.length);
+		payload = ids;
+	}
 
-    public PDU(PDU... set) {
-        this(SEQUENCE+CONSTRUCTED,set);
-    }
+	public PDU(int tag, PDU... set) {
+		this(tag, (Object) set);
+	}
 
+	public PDU(PDU... set) {
+		this(SEQUENCE + CONSTRUCTED, set);
+	}
 
-    public int getTag() {
-        return identifier & TAGMASK;
-    }
+	public int getTag() {
+		return identifier & TAGMASK;
+	}
 
-    int getClss() {
-        return identifier & CLASSMASK;
-    }
+	int getClss() {
+		return identifier & CLASSMASK;
+	}
 
-    public boolean isConstructed() {
-        return (identifier & CONSTRUCTED) != 0;
-    }
+	public boolean isConstructed() {
+		return (identifier & CONSTRUCTED) != 0;
+	}
 
-    public String getString() {
-        return (String) payload;
-    }
+	public String getString() {
+		return (String) payload;
+	}
 
-    public Iterator<PDU> iterator() {
-        return Arrays.asList((PDU[]) payload).iterator();
-    }
+	public Iterator<PDU> iterator() {
+		return Arrays.asList((PDU[]) payload).iterator();
+	}
 
-    
-    public int[] getOID() {
-        assert getTag() == OBJECT_IDENTIFIER;
-        return (int[]) payload;
-    }
+	public int[] getOID() {
+		assert getTag() == OBJECT_IDENTIFIER;
+		return (int[]) payload;
+	}
 
-    public Boolean getBoolean() {
-        assert getTag() == BOOLEAN;
-        return (Boolean) payload;
-    }
+	public Boolean getBoolean() {
+		assert getTag() == BOOLEAN;
+		return (Boolean) payload;
+	}
 
-    public BitSet getBits() {
-        assert getTag() == BIT_STRING;
-        return (BitSet) payload;
-    }
+	public BitSet getBits() {
+		assert getTag() == BIT_STRING;
+		return (BitSet) payload;
+	}
 
-    public int getInt() {
-        assert getTag() == INTEGER || getTag() == ENUMERATED;
-        return (Integer) payload;
-    }
+	public int getInt() {
+		assert getTag() == INTEGER || getTag() == ENUMERATED;
+		return (Integer) payload;
+	}
 
-    public byte[] getBytes() {
-        return (byte[]) payload;
-    }
+	public byte[] getBytes() {
+		return (byte[]) payload;
+	}
 
-    public PDU[] getChildren() {
-        assert isConstructed();
-        return (PDU[]) payload;
-    }
+	public PDU[] getChildren() {
+		assert isConstructed();
+		return (PDU[]) payload;
+	}
 
-    public Date getDate() {
-        assert getTag() == UTCTIME || getTag() == GENERALIZED_TIME;
-        return (Date) payload;
-    }
+	public Date getDate() {
+		assert getTag() == UTCTIME || getTag() == GENERALIZED_TIME;
+		return (Date) payload;
+	}
 
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/asn1/Types.java b/bundleplugin/src/main/java/aQute/libg/asn1/Types.java
index 630ed1c..8f189ed 100644
--- a/bundleplugin/src/main/java/aQute/libg/asn1/Types.java
+++ b/bundleplugin/src/main/java/aQute/libg/asn1/Types.java
@@ -1,65 +1,66 @@
 package aQute.libg.asn1;
 
 public interface Types {
-    int      UNIVERSAL         = 0x00000000;
-    int      APPLICATION       = 0x40000000;
-    int      CONTEXT           = 0x80000000;
-    int      PRIVATE           = 0xC0000000;
-    int      CLASSMASK         = 0xC0000000;
-    int      CONSTRUCTED       = 0x20000000;
-    int      TAGMASK           = 0x1FFFFFFF;
+	int			UNIVERSAL			= 0x00000000;
+	int			APPLICATION			= 0x40000000;
+	int			CONTEXT				= 0x80000000;
+	int			PRIVATE				= 0xC0000000;
+	int			CLASSMASK			= 0xC0000000;
+	int			CONSTRUCTED			= 0x20000000;
+	int			TAGMASK				= 0x1FFFFFFF;
 
-    String [] CLASSES = {"U", "A", "C", "P"};
-    
-    // Payload Primitve
-    int      EOC               = 0;                                // null
-    // x
-    int      BOOLEAN           = 1;                                // Boolean
-    // x
-    int      INTEGER           = 2;                                // Long
-    // x
-    int      BIT_STRING        = 3;                                // byte
-    // [] -
-    int      OCTET_STRING      = 4;                                // byte
-    // [] -
-    int      NULL              = 5;                                // null
-    // x
-    int      OBJECT_IDENTIFIER = 6;                                // int[]
-    // x
-    int      OBJECT_DESCRIPTOR = 7;                                // 
-    int      EXTERNAL          = 8;                                //
-    int      REAL              = 9;                                // double
-    // x
-    int      ENUMERATED        = 10;                               // 
-    int      EMBEDDED_PDV      = 11;                               //
-    int      UTF8_STRING       = 12;                               // String
-    int      RELATIVE_OID      = 13;                               // 
-    int      SEQUENCE          = 16;                               // 
-    int      SET               = 17;
-    int      NUMERIC_STRING    = 18;                               // String
-    int      PRINTABLE_STRING  = 19;                               // String
-    int      T61_STRING        = 20;                               // String
-    int      VIDEOTEX_STRING   = 21;                               // String
-    int      IA5STRING         = 22;                               // String
-    int      UTCTIME           = 23;                               // Date
-    int      GENERALIZED_TIME  = 24;                               // Date
-    int      GRAPHIC_STRING    = 25;                               // String
-    int      VISIBLE_STRING    = 26;                               // String
-    int      GENERAL_STRING    = 27;                               // String
-    int      UNIVERSAL_STRING  = 28;                               // String
-    int      CHARACTER_STRING  = 29;                               // String
-    int      BMP_STRING        = 30;                               // byte[]
+	String[]	CLASSES				= {
+			"U", "A", "C", "P"
+									};
 
-    String[] TAGS              = { "EOC               ",
-            "BOOLEAN           ", "INTEGER           ", "BIT_STRING        ",
-            "OCTET_STRING      ", "NULL              ", "OBJECT_IDENTIFIER ",
-            "OBJECT_DESCRIPTOR ", "EXTERNAL          ", "REAL              ",
-            "ENUMERATED        ", "EMBEDDED_PDV      ", "UTF8_STRING       ",
-            "RELATIVE_OID      ", "?(14)             ", "?(15)             ",
-            "SEQUENCE          ", "SET               ", "NUMERIC_STRING    ",
-            "PRINTABLE_STRING  ", "T61_STRING        ", "VIDEOTEX_STRING   ",
-            "IA5STRING         ", "UTCTIME           ", "GENERALIZED_TIME  ",
-            "GRAPHIC_STRING    ", "VISIBLE_STRING    ", "GENERAL_STRING    ",
-            "UNIVERSAL_STRING  ", "CHARACTER_STRING  ", "BMP_STRING        ", };
+	// Payload Primitve
+	int			EOC					= 0;			// null
+	// x
+	int			BOOLEAN				= 1;			// Boolean
+	// x
+	int			INTEGER				= 2;			// Long
+	// x
+	int			BIT_STRING			= 3;			// byte
+	// [] -
+	int			OCTET_STRING		= 4;			// byte
+	// [] -
+	int			NULL				= 5;			// null
+	// x
+	int			OBJECT_IDENTIFIER	= 6;			// int[]
+	// x
+	int			OBJECT_DESCRIPTOR	= 7;			//
+	int			EXTERNAL			= 8;			//
+	int			REAL				= 9;			// double
+	// x
+	int			ENUMERATED			= 10;			//
+	int			EMBEDDED_PDV		= 11;			//
+	int			UTF8_STRING			= 12;			// String
+	int			RELATIVE_OID		= 13;			//
+	int			SEQUENCE			= 16;			//
+	int			SET					= 17;
+	int			NUMERIC_STRING		= 18;			// String
+	int			PRINTABLE_STRING	= 19;			// String
+	int			T61_STRING			= 20;			// String
+	int			VIDEOTEX_STRING		= 21;			// String
+	int			IA5STRING			= 22;			// String
+	int			UTCTIME				= 23;			// Date
+	int			GENERALIZED_TIME	= 24;			// Date
+	int			GRAPHIC_STRING		= 25;			// String
+	int			VISIBLE_STRING		= 26;			// String
+	int			GENERAL_STRING		= 27;			// String
+	int			UNIVERSAL_STRING	= 28;			// String
+	int			CHARACTER_STRING	= 29;			// String
+	int			BMP_STRING			= 30;			// byte[]
+
+	String[]	TAGS				= {
+			"EOC               ", "BOOLEAN           ", "INTEGER           ", "BIT_STRING        ",
+			"OCTET_STRING      ", "NULL              ", "OBJECT_IDENTIFIER ", "OBJECT_DESCRIPTOR ",
+			"EXTERNAL          ", "REAL              ", "ENUMERATED        ", "EMBEDDED_PDV      ",
+			"UTF8_STRING       ", "RELATIVE_OID      ", "?(14)             ", "?(15)             ",
+			"SEQUENCE          ", "SET               ", "NUMERIC_STRING    ", "PRINTABLE_STRING  ",
+			"T61_STRING        ", "VIDEOTEX_STRING   ", "IA5STRING         ", "UTCTIME           ",
+			"GENERALIZED_TIME  ", "GRAPHIC_STRING    ", "VISIBLE_STRING    ", "GENERAL_STRING    ",
+			"UNIVERSAL_STRING  ", "CHARACTER_STRING  ", "BMP_STRING        ",
+									};
 
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/cafs/CAFS.java b/bundleplugin/src/main/java/aQute/libg/cafs/CAFS.java
index 0bb8d7b..38e67be 100644
--- a/bundleplugin/src/main/java/aQute/libg/cafs/CAFS.java
+++ b/bundleplugin/src/main/java/aQute/libg/cafs/CAFS.java
@@ -17,7 +17,6 @@
  * in the universe has a unique SHA-1. Hard to believe but people smarter than
  * me have come to that conclusion. This class maintains a compressed store of
  * SHA-1 identified files. So if you have the SHA-1, you can get the contents.
- * 
  * This makes it easy to store a SHA-1 instead of the whole file or maintain a
  * naming scheme. An added advantage is that it is always easy to verify you get
  * the right stuff. The SHA-1 Content Addressable File Store is the core
@@ -34,9 +33,9 @@
 												+ 4 // flags
 												+ 4 // compressed length
 												+ 4 // uncompressed length
-												+ KEYLENGTH	// key
+												+ KEYLENGTH // key
 												+ 2 // header checksum
-												;
+										;
 
 	final File			home;
 	Index				index;
@@ -69,8 +68,7 @@
 					store.writeInt(0);
 				channel.force(true);
 			} else
-				throw new IllegalArgumentException("Invalid store file, length is too short "
-						+ store);
+				throw new IllegalArgumentException("Invalid store file, length is too short " + store);
 			System.err.println(store.length());
 		}
 		store.seek(0);
@@ -101,7 +99,7 @@
 		synchronized (store) {
 			// First check if it already exists
 			SHA1 sha1 = new SHA1(md.digest());
-			
+
 			long search = index.search(sha1.digest());
 			if (search > 0)
 				return sha1;
@@ -136,7 +134,8 @@
 				update(sha1.digest(), compressed, totalLength);
 				index.insert(sha1.digest(), insertPoint);
 				return sha1;
-			} finally {
+			}
+			finally {
 				if (lock != null)
 					lock.release();
 			}
@@ -163,20 +162,20 @@
 			if (!verifySignature(store, CAFE))
 				throw new IllegalArgumentException("No signature");
 
-			int flags =store.readInt();
+			int flags = store.readInt();
 			int compressedLength = store.readInt();
 			int uncompressedLength = store.readInt();
 			readSha1 = new byte[KEYLENGTH];
 			store.read(readSha1);
 			SHA1 rsha1 = new SHA1(readSha1);
-			
+
 			if (!sha1.equals(rsha1))
 				throw new IOException("SHA1 read and asked mismatch: " + sha1 + " " + rsha1);
 
 			short crc = store.readShort(); // Read CRC
-			if ( crc != checksum(flags,compressedLength, uncompressedLength, readSha1))
+			if (crc != checksum(flags, compressedLength, uncompressedLength, readSha1))
 				throw new IllegalArgumentException("Invalid header checksum: " + sha1);
-			
+
 			buffer = new byte[compressedLength];
 			store.readFully(buffer);
 			return getSha1Stream(sha1, buffer, uncompressedLength);
@@ -192,8 +191,7 @@
 		synchronized (store) {
 			length = store.length();
 			if (length < 0x100)
-				throw new IllegalArgumentException(
-						"Store file is too small, need to be at least 256 bytes: " + store);
+				throw new IllegalArgumentException("Store file is too small, need to be at least 256 bytes: " + store);
 		}
 
 		RandomAccessFile in = new RandomAccessFile(new File(home, STOREFILE), "r");
@@ -219,7 +217,8 @@
 				ixf.renameTo(indexFile);
 				this.index = new Index(indexFile, KEYLENGTH);
 			}
-		} finally {
+		}
+		finally {
 			in.close();
 		}
 	}
@@ -228,7 +227,8 @@
 		synchronized (store) {
 			try {
 				store.close();
-			} finally {
+			}
+			finally {
 				index.close();
 			}
 		}
@@ -246,7 +246,7 @@
 		byte[] key = new byte[KEYLENGTH];
 		in.readFully(key);
 		SHA1 sha1 = new SHA1(key);
-		
+
 		byte[] buffer = new byte[compressedSize];
 		in.readFully(buffer);
 
@@ -262,20 +262,20 @@
 		return Arrays.equals(read, org);
 	}
 
-	private InputStream getSha1Stream(final SHA1 sha1, byte[] buffer, final int total)
-			throws NoSuchAlgorithmException {
+	private InputStream getSha1Stream(final SHA1 sha1, byte[] buffer, final int total) throws NoSuchAlgorithmException {
 		ByteArrayInputStream in = new ByteArrayInputStream(buffer);
 		InflaterInputStream iin = new InflaterInputStream(in) {
-			int count = 0;
-			final MessageDigest digestx = MessageDigest.getInstance(ALGORITHM);
-			final AtomicBoolean calculated = new AtomicBoolean();
-			
-			@Override public int read(byte[] data, int offset, int length) throws IOException {
+			int					count		= 0;
+			final MessageDigest	digestx		= MessageDigest.getInstance(ALGORITHM);
+			final AtomicBoolean	calculated	= new AtomicBoolean();
+
+			@Override
+			public int read(byte[] data, int offset, int length) throws IOException {
 				int size = super.read(data, offset, length);
 				if (size <= 0)
 					eof();
 				else {
-					count+=size;
+					count += size;
 					this.digestx.update(data, offset, size);
 				}
 				return size;
@@ -293,16 +293,17 @@
 			}
 
 			void eof() throws IOException {
-				if ( calculated.getAndSet(true))
+				if (calculated.getAndSet(true))
 					return;
-				
-				if ( count != total )
-					throw new IOException("Counts do not match. Expected to read: " + total + " Actually read: " + count);
-				
+
+				if (count != total)
+					throw new IOException("Counts do not match. Expected to read: " + total + " Actually read: "
+							+ count);
+
 				SHA1 calculatedSha1 = new SHA1(digestx.digest());
 				if (!sha1.equals(calculatedSha1))
-					throw ( new IOException("SHA1 caclulated and asked mismatch, asked: "
-							+ sha1 + ", \nfound: " +calculatedSha1));
+					throw (new IOException("SHA1 caclulated and asked mismatch, asked: " + sha1 + ", \nfound: "
+							+ calculatedSha1));
 			}
 
 			public void close() throws IOException {
@@ -327,87 +328,86 @@
 	 *             The exception
 	 */
 	private void update(byte[] sha1, byte[] compressed, int totalLength) throws IOException {
-		//System.err.println("pos: " + store.getFilePointer());
+		// System.err.println("pos: " + store.getFilePointer());
 		store.write(CAFE); // 00-03 Signature
 		store.writeInt(0); // 04-07 Flags for the future
 		store.writeInt(compressed.length); // 08-11 Length deflated data
 		store.writeInt(totalLength); // 12-15 Length
 		store.write(sha1); // 16-35
-		store.writeShort( checksum(0,compressed.length, totalLength, sha1));
+		store.writeShort(checksum(0, compressed.length, totalLength, sha1));
 		store.write(compressed);
 		channel.force(false);
 	}
 
-	
-	
 	private short checksum(int flags, int compressedLength, int totalLength, byte[] sha1) {
 		CRC32 crc = new CRC32();
 		crc.update(flags);
-		crc.update(flags>>8);
-		crc.update(flags>>16);
-		crc.update(flags>>24);
+		crc.update(flags >> 8);
+		crc.update(flags >> 16);
+		crc.update(flags >> 24);
 		crc.update(compressedLength);
-		crc.update(compressedLength>>8);
-		crc.update(compressedLength>>16);
-		crc.update(compressedLength>>24);
+		crc.update(compressedLength >> 8);
+		crc.update(compressedLength >> 16);
+		crc.update(compressedLength >> 24);
 		crc.update(totalLength);
-		crc.update(totalLength>>8);
-		crc.update(totalLength>>16);
-		crc.update(totalLength>>24);
+		crc.update(totalLength >> 8);
+		crc.update(totalLength >> 16);
+		crc.update(totalLength >> 24);
 		crc.update(sha1);
 		return (short) crc.getValue();
 	}
 
 	public Iterator<SHA1> iterator() {
-		
+
 		return new Iterator<SHA1>() {
-			long position = 0x100;
-			
+			long	position	= 0x100;
+
 			public boolean hasNext() {
-				synchronized(store) {
+				synchronized (store) {
 					try {
 						return position < store.length();
-					} catch (IOException e) {
+					}
+					catch (IOException e) {
 						throw new RuntimeException(e);
 					}
 				}
 			}
 
 			public SHA1 next() {
-				synchronized(store) {
+				synchronized (store) {
 					try {
 						store.seek(position);
-						byte [] signature = new byte[4];
+						byte[] signature = new byte[4];
 						store.readFully(signature);
-						if ( !Arrays.equals(CAFE, signature))
+						if (!Arrays.equals(CAFE, signature))
 							throw new IllegalArgumentException("No signature");
 
 						int flags = store.readInt();
 						int compressedLength = store.readInt();
 						int totalLength = store.readInt();
-						byte []sha1 = new byte[KEYLENGTH];
+						byte[] sha1 = new byte[KEYLENGTH];
 						store.readFully(sha1);
 						short crc = store.readShort();
-						if ( crc != checksum(flags,compressedLength, totalLength, sha1))
+						if (crc != checksum(flags, compressedLength, totalLength, sha1))
 							throw new IllegalArgumentException("Header checksum fails");
-						
+
 						position += HEADERLENGTH + compressedLength;
 						return new SHA1(sha1);
-					} catch (IOException e) {
+					}
+					catch (IOException e) {
 						throw new RuntimeException(e);
-					}				
+					}
 				}
 			}
 
 			public void remove() {
 				throw new UnsupportedOperationException("Remvoe not supported, CAFS is write once");
-			}			
+			}
 		};
 	}
 
-	
 	public boolean isEmpty() throws IOException {
-		synchronized(store) {
+		synchronized (store) {
 			return store.getFilePointer() <= 256;
 		}
 	}
diff --git a/bundleplugin/src/main/java/aQute/libg/classdump/ClassDumper.java b/bundleplugin/src/main/java/aQute/libg/classdump/ClassDumper.java
index e45cd39..adf9824 100755
--- a/bundleplugin/src/main/java/aQute/libg/classdump/ClassDumper.java
+++ b/bundleplugin/src/main/java/aQute/libg/classdump/ClassDumper.java
@@ -6,693 +6,645 @@
 import java.lang.reflect.*;
 
 public class ClassDumper {
-    /**
-     * <pre>
-     * ACC_PUBLIC 0x0001 Declared public; may be accessed from outside its
-     * package. 
-     * ACC_FINAL 0x0010 Declared final; no subclasses allowed.
-     * ACC_SUPER 0x0020 Treat superclass methods specially when invoked by the
-     * invokespecial instruction. 
-     * ACC_INTERFACE 0x0200 Is an interface, not a
-     * class. 
-     * ACC_ABSTRACT 0x0400 Declared abstract; may not be instantiated.
-     * </pre>
-     * 
-     * @param mod
-     */
-    final static int ACC_PUBLIC  = 0x0001; // Declared public; may be accessed
-                                            // from outside its package.
-    final static int ACC_FINAL     = 0x0010; // Declared final; no subclasses
-    // allowed.
-    final static int ACC_SUPER     = 0x0020; // Treat superclass methods
-    // specially when invoked by the
-    // invokespecial instruction.
-    final static int ACC_INTERFACE = 0x0200; // Is an interface, not a classs
-    final static int ACC_ABSTRACT  = 0x0400; // Declared abstract; may not be
-                                                // instantiated.
-    
-    final static class Assoc {
-        Assoc(byte tag, int a, int b) {
-            this.tag = tag;
-            this.a = a;
-            this.b = b;
-        }
+	/**
+	 * <pre>
+	 * ACC_PUBLIC 0x0001 Declared public; may be accessed from outside its
+	 * package. 
+	 * ACC_FINAL 0x0010 Declared final; no subclasses allowed.
+	 * ACC_SUPER 0x0020 Treat superclass methods specially when invoked by the
+	 * invokespecial instruction. 
+	 * ACC_INTERFACE 0x0200 Is an interface, not a
+	 * class. 
+	 * ACC_ABSTRACT 0x0400 Declared abstract; may not be instantiated.
+	 * </pre>
+	 * 
+	 * @param mod
+	 */
+	final static int	ACC_PUBLIC		= 0x0001;	// Declared public; may be
+													// accessed
+													// from outside its package.
+	final static int	ACC_FINAL		= 0x0010;	// Declared final; no
+													// subclasses
+	// allowed.
+	final static int	ACC_SUPER		= 0x0020;	// Treat superclass methods
+	// specially when invoked by the
+	// invokespecial instruction.
+	final static int	ACC_INTERFACE	= 0x0200;	// Is an interface, not a
+													// classs
+	final static int	ACC_ABSTRACT	= 0x0400;	// Declared abstract; may
+													// not be
+													// instantiated.
 
-        byte tag;
-        int  a;
-        int  b;
+	final static class Assoc {
+		Assoc(byte tag, int a, int b) {
+			this.tag = tag;
+			this.a = a;
+			this.b = b;
+		}
 
-    }
+		byte	tag;
+		int		a;
+		int		b;
 
-    final String        path;
-    final static String NUM_COLUMN = "%-30s %d\n";
-    final static String HEX_COLUMN = "%-30s %x\n";
-    final static String STR_COLUMN = "%-30s %s\n";
+	}
 
-    PrintStream         ps         = System.err;
-    Object[]            pool;
-    InputStream         in;
+	final String		path;
+	final static String	NUM_COLUMN	= "%-30s %d\n";
+	final static String	HEX_COLUMN	= "%-30s %x\n";
+	final static String	STR_COLUMN	= "%-30s %s\n";
 
-    public ClassDumper(String path) throws Exception {
-        this(path, new FileInputStream(new File(path)));
-    }
+	PrintStream			ps			= System.err;
+	Object[]			pool;
+	InputStream			in;
 
-    public ClassDumper(String path, InputStream in) throws IOException {
-        this.path = path;
-        this.in = in;
-    }
+	public ClassDumper(String path) throws Exception {
+		this(path, new FileInputStream(new File(path)));
+	}
 
-    public void dump(PrintStream ps) throws Exception {
-        if (ps != null)
-            this.ps = ps;
-        DataInputStream din = new DataInputStream(in);
-        parseClassFile(din);
-        din.close();
-    }
+	public ClassDumper(String path, InputStream in) throws IOException {
+		this.path = path;
+		this.in = in;
+	}
 
-    void parseClassFile(DataInputStream in) throws IOException {
-        int magic = in.readInt();
-        if (magic != 0xCAFEBABE)
-            throw new IOException("Not a valid class file (no CAFEBABE header)");
+	public void dump(PrintStream ps) throws Exception {
+		if (ps != null)
+			this.ps = ps;
+		DataInputStream din = new DataInputStream(in);
+		parseClassFile(din);
+		din.close();
+	}
 
-        ps.printf(HEX_COLUMN, "magic", magic);
-        int minor = in.readUnsignedShort(); // minor version
-        int major = in.readUnsignedShort(); // major version
-        ps.printf(STR_COLUMN, "version", "" + major + "." + minor);
-        int pool_size = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, "pool size", pool_size);
-        pool = new Object[pool_size];
+	void parseClassFile(DataInputStream in) throws IOException {
+		int magic = in.readInt();
+		if (magic != 0xCAFEBABE)
+			throw new IOException("Not a valid class file (no CAFEBABE header)");
 
-        process: for (int poolIndex = 1; poolIndex < pool_size; poolIndex++) {
-            byte tag = in.readByte();
+		ps.printf(HEX_COLUMN, "magic", magic);
+		int minor = in.readUnsignedShort(); // minor version
+		int major = in.readUnsignedShort(); // major version
+		ps.printf(STR_COLUMN, "version", "" + major + "." + minor);
+		int pool_size = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, "pool size", pool_size);
+		pool = new Object[pool_size];
 
-            switch (tag) {
-            case 0:
-                ps.printf("%30d tag (0)\n", poolIndex);
-                break process;
+		process: for (int poolIndex = 1; poolIndex < pool_size; poolIndex++) {
+			byte tag = in.readByte();
 
-            case 1:
-                String name = in.readUTF();
-                pool[poolIndex] = name;
-                ps.printf("%30d tag(1) utf8 '%s'\n", poolIndex, name);
-                break;
+			switch (tag) {
+				case 0 :
+					ps.printf("%30d tag (0)\n", poolIndex);
+					break process;
 
-            case 2:
-                throw new IOException("Invalid tag " + tag);
+				case 1 :
+					String name = in.readUTF();
+					pool[poolIndex] = name;
+					ps.printf("%30d tag(1) utf8 '%s'\n", poolIndex, name);
+					break;
 
-            case 3:
-                int i = in.readInt();
-                pool[poolIndex] = Integer.valueOf(i);
-                ps.printf("%30d tag(3) int %s\n", poolIndex, i);
-                break;
+				case 2 :
+					throw new IOException("Invalid tag " + tag);
 
-            case 4:
-                float f = in.readFloat();
-                pool[poolIndex] = new Float(f);
-                ps.printf("%30d tag(4) float %s\n", poolIndex, f);
-                break;
+				case 3 :
+					int i = in.readInt();
+					pool[poolIndex] = Integer.valueOf(i);
+					ps.printf("%30d tag(3) int %s\n", poolIndex, i);
+					break;
 
-            // For some insane optimization reason are
-            // the long and the double two entries in the
-            // constant pool. See 4.4.5
-            case 5:
-                long l = in.readLong();
-                pool[poolIndex] = Long.valueOf(l);
-                ps.printf("%30d tag(5) long %s\n", poolIndex, l);
-                poolIndex++;
-                break;
+				case 4 :
+					float f = in.readFloat();
+					pool[poolIndex] = new Float(f);
+					ps.printf("%30d tag(4) float %s\n", poolIndex, f);
+					break;
 
-            case 6:
-                double d = in.readDouble();
-                pool[poolIndex] = new Double(d);
-                ps.printf("%30d tag(6) double %s\n", poolIndex, d);
-                poolIndex++;
-                break;
+				// For some insane optimization reason are
+				// the long and the double two entries in the
+				// constant pool. See 4.4.5
+				case 5 :
+					long l = in.readLong();
+					pool[poolIndex] = Long.valueOf(l);
+					ps.printf("%30d tag(5) long %s\n", poolIndex, l);
+					poolIndex++;
+					break;
 
-            case 7:
-                int class_index = in.readUnsignedShort();
-                pool[poolIndex] = Integer.valueOf(class_index);
-                ps.printf("%30d tag(7) constant classs %d\n", poolIndex,
-                        class_index);
-                break;
+				case 6 :
+					double d = in.readDouble();
+					pool[poolIndex] = new Double(d);
+					ps.printf("%30d tag(6) double %s\n", poolIndex, d);
+					poolIndex++;
+					break;
 
-            case 8:
-                int string_index = in.readUnsignedShort();
-                pool[poolIndex] = Integer.valueOf(string_index);
-                ps.printf("%30d tag(8) constant string %d\n", poolIndex,
-                        string_index);
-                break;
+				case 7 :
+					int class_index = in.readUnsignedShort();
+					pool[poolIndex] = Integer.valueOf(class_index);
+					ps.printf("%30d tag(7) constant classs %d\n", poolIndex, class_index);
+					break;
 
-            case 9: // Field ref
-                class_index = in.readUnsignedShort();
-                int name_and_type_index = in.readUnsignedShort();
-                pool[poolIndex] = new Assoc((byte) 9, class_index,
-                        name_and_type_index);
-                ps.printf("%30d tag(9) field ref %d/%d\n", poolIndex,
-                        class_index, name_and_type_index);
-                break;
+				case 8 :
+					int string_index = in.readUnsignedShort();
+					pool[poolIndex] = Integer.valueOf(string_index);
+					ps.printf("%30d tag(8) constant string %d\n", poolIndex, string_index);
+					break;
 
-            case 10: // Method ref
-                class_index = in.readUnsignedShort();
-                name_and_type_index = in.readUnsignedShort();
-                pool[poolIndex] = new Assoc((byte) 10, class_index,
-                        name_and_type_index);
-                ps.printf("%30d tag(10) method ref %d/%d\n", poolIndex,
-                        class_index, name_and_type_index);
-                break;
+				case 9 : // Field ref
+					class_index = in.readUnsignedShort();
+					int name_and_type_index = in.readUnsignedShort();
+					pool[poolIndex] = new Assoc((byte) 9, class_index, name_and_type_index);
+					ps.printf("%30d tag(9) field ref %d/%d\n", poolIndex, class_index, name_and_type_index);
+					break;
 
-            case 11: // Interface and Method ref
-                class_index = in.readUnsignedShort();
-                name_and_type_index = in.readUnsignedShort();
-                pool[poolIndex] = new Assoc((byte) 11, class_index,
-                        name_and_type_index);
-                ps.printf("%30d tag(11) interface and method ref %d/%d\n",
-                        poolIndex, class_index, name_and_type_index);
-                break;
+				case 10 : // Method ref
+					class_index = in.readUnsignedShort();
+					name_and_type_index = in.readUnsignedShort();
+					pool[poolIndex] = new Assoc((byte) 10, class_index, name_and_type_index);
+					ps.printf("%30d tag(10) method ref %d/%d\n", poolIndex, class_index, name_and_type_index);
+					break;
 
-            // Name and Type
-            case 12:
-                int name_index = in.readUnsignedShort();
-                int descriptor_index = in.readUnsignedShort();
-                pool[poolIndex] = new Assoc(tag, name_index, descriptor_index);
-                ps.printf("%30d tag(12) name and type %d/%d\n", poolIndex,
-                        name_index, descriptor_index);
-                break;
+				case 11 : // Interface and Method ref
+					class_index = in.readUnsignedShort();
+					name_and_type_index = in.readUnsignedShort();
+					pool[poolIndex] = new Assoc((byte) 11, class_index, name_and_type_index);
+					ps.printf("%30d tag(11) interface and method ref %d/%d\n", poolIndex, class_index,
+							name_and_type_index);
+					break;
 
-            default:
-                throw new IllegalArgumentException("Unknown tag: " + tag);
-            }
-        }
+				// Name and Type
+				case 12 :
+					int name_index = in.readUnsignedShort();
+					int descriptor_index = in.readUnsignedShort();
+					pool[poolIndex] = new Assoc(tag, name_index, descriptor_index);
+					ps.printf("%30d tag(12) name and type %d/%d\n", poolIndex, name_index, descriptor_index);
+					break;
 
-        int access = in.readUnsignedShort(); // access
-        printAccess(access);
-        int this_class = in.readUnsignedShort();
-        int super_class = in.readUnsignedShort();
-        ps.printf("%-30s %x %s(#%d)\n", "this_class", access, pool[this_class],
-                this_class);
-        ps.printf("%-30s %s(#%d)\n", "super_class", pool[super_class],
-                super_class);
+				default :
+					throw new IllegalArgumentException("Unknown tag: " + tag);
+			}
+		}
 
-        int interfaces_count = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, "interface count", interfaces_count);
-        for (int i = 0; i < interfaces_count; i++) {
-            int interface_index = in.readUnsignedShort();
-            ps.printf("%-30s interface %s(#%d)", "interface count",
-                    pool[interface_index], interfaces_count);
-        }
+		int access = in.readUnsignedShort(); // access
+		printAccess(access);
+		int this_class = in.readUnsignedShort();
+		int super_class = in.readUnsignedShort();
+		ps.printf("%-30s %x %s(#%d)\n", "this_class", access, pool[this_class], this_class);
+		ps.printf("%-30s %s(#%d)\n", "super_class", pool[super_class], super_class);
 
-        int field_count = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, "field count", field_count);
-        for (int i = 0; i < field_count; i++) {
-            access = in.readUnsignedShort(); // access
-            printAccess(access);
-            int name_index = in.readUnsignedShort();
-            int descriptor_index = in.readUnsignedShort();
-            ps.printf("%-30s %x %s(#%d) %s(#%d)\n", "field def", access,
-                    pool[name_index], name_index, pool[descriptor_index],
-                    descriptor_index);
-            doAttributes(in, "  ");
-        }
+		int interfaces_count = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, "interface count", interfaces_count);
+		for (int i = 0; i < interfaces_count; i++) {
+			int interface_index = in.readUnsignedShort();
+			ps.printf("%-30s interface %s(#%d)", "interface count", pool[interface_index], interfaces_count);
+		}
 
-        int method_count = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, "method count", method_count);
-        for (int i = 0; i < method_count; i++) {
-            int access_flags = in.readUnsignedShort();
-            printAccess(access_flags);
-            int name_index = in.readUnsignedShort();
-            int descriptor_index = in.readUnsignedShort();
-            ps.printf("%-30s %x %s(#%d) %s(#%d)\n", "method def", access_flags,
-                    pool[name_index], name_index, pool[descriptor_index],
-                    descriptor_index);
-            doAttributes(in, "  ");
-        }
+		int field_count = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, "field count", field_count);
+		for (int i = 0; i < field_count; i++) {
+			access = in.readUnsignedShort(); // access
+			printAccess(access);
+			int name_index = in.readUnsignedShort();
+			int descriptor_index = in.readUnsignedShort();
+			ps.printf("%-30s %x %s(#%d) %s(#%d)\n", "field def", access, pool[name_index], name_index,
+					pool[descriptor_index], descriptor_index);
+			doAttributes(in, "  ");
+		}
 
-        doAttributes(in, "");
-        if (in.read() >= 0)
-            ps.printf("Extra bytes follow ...");
-    }
+		int method_count = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, "method count", method_count);
+		for (int i = 0; i < method_count; i++) {
+			int access_flags = in.readUnsignedShort();
+			printAccess(access_flags);
+			int name_index = in.readUnsignedShort();
+			int descriptor_index = in.readUnsignedShort();
+			ps.printf("%-30s %x %s(#%d) %s(#%d)\n", "method def", access_flags, pool[name_index], name_index,
+					pool[descriptor_index], descriptor_index);
+			doAttributes(in, "  ");
+		}
 
-    /**
-     * Called for each attribute in the class, field, or method.
-     * 
-     * @param in
-     *            The stream
-     * @throws IOException
-     */
-    private void doAttributes(DataInputStream in, String indent)
-            throws IOException {
-        int attribute_count = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "attribute count", attribute_count);
-        for (int j = 0; j < attribute_count; j++) {
-            doAttribute(in, indent + j + ": ");
-        }
-    }
+		doAttributes(in, "");
+		if (in.read() >= 0)
+			ps.printf("Extra bytes follow ...");
+	}
 
-    /**
-     * Process a single attribute, if not recognized, skip it.
-     * 
-     * @param in
-     *            the data stream
-     * @throws IOException
-     */
-    private void doAttribute(DataInputStream in, String indent)
-            throws IOException {
-        int attribute_name_index = in.readUnsignedShort();
-        long attribute_length = in.readInt();
-        attribute_length &= 0xFFFF;
-        String attributeName = (String) pool[attribute_name_index];
-        ps.printf("%-30s %s(#%d)\n", indent + "attribute", attributeName,
-                attribute_name_index);
-        if ("RuntimeVisibleAnnotations".equals(attributeName))
-            doAnnotations(in, indent);
-        else if ("SourceFile".equals(attributeName))
-            doSourceFile(in, indent);
-        else if ("Code".equals(attributeName))
-            doCode(in, indent);
-        else if ("LineNumberTable".equals(attributeName))
-            doLineNumberTable(in, indent);
-        else if ("LocalVariableTable".equals(attributeName))
-            doLocalVariableTable(in, indent);
-        else if ("InnerClasses".equals(attributeName))
-            doInnerClasses(in, indent);
-        else if ("Exceptions".equals(attributeName))
-            doExceptions(in, indent);
-        else if ("EnclosingMethod".equals(attributeName))
-            doEnclosingMethod(in, indent);
-        else if ("Signature".equals(attributeName))
-            doSignature(in, indent);
-        else if ("Synthetic".equals(attributeName))
-            ; // Is empty!
-        else if ("Deprecated".equals(attributeName))
-            ; // Is Empty
-        else {
-            ps.printf("%-30s %d\n", indent + "Unknown attribute, skipping",
-                    attribute_length);
-            if (attribute_length > 0x7FFFFFFF) {
-                throw new IllegalArgumentException("Attribute > 2Gb");
-            }
-            byte buffer[] = new byte[(int) attribute_length];
-            in.readFully(buffer);
-            printHex(buffer);
-        }
-    }
+	/**
+	 * Called for each attribute in the class, field, or method.
+	 * 
+	 * @param in
+	 *            The stream
+	 * @throws IOException
+	 */
+	private void doAttributes(DataInputStream in, String indent) throws IOException {
+		int attribute_count = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "attribute count", attribute_count);
+		for (int j = 0; j < attribute_count; j++) {
+			doAttribute(in, indent + j + ": ");
+		}
+	}
 
-    /**
-     * <pre>
-     * Signature_attribute {
-     * 	u2 attribute_name_index;
-     * 	u4 attribute_length;
-     * 	u2 signature_index;
-     * 	}
-     * </pre>
-     * 
-     * @param in
-     * @param indent
-     */
-    void doSignature(DataInputStream in, String indent) throws IOException {
-        int signature_index = in.readUnsignedShort();
-        ps.printf("%-30s %s(#%d)\n", indent + "signature",
-                pool[signature_index], signature_index);
-    }
+	/**
+	 * Process a single attribute, if not recognized, skip it.
+	 * 
+	 * @param in
+	 *            the data stream
+	 * @throws IOException
+	 */
+	private void doAttribute(DataInputStream in, String indent) throws IOException {
+		int attribute_name_index = in.readUnsignedShort();
+		long attribute_length = in.readInt();
+		attribute_length &= 0xFFFF;
+		String attributeName = (String) pool[attribute_name_index];
+		ps.printf("%-30s %s(#%d)\n", indent + "attribute", attributeName, attribute_name_index);
+		if ("RuntimeVisibleAnnotations".equals(attributeName))
+			doAnnotations(in, indent);
+		else if ("SourceFile".equals(attributeName))
+			doSourceFile(in, indent);
+		else if ("Code".equals(attributeName))
+			doCode(in, indent);
+		else if ("LineNumberTable".equals(attributeName))
+			doLineNumberTable(in, indent);
+		else if ("LocalVariableTable".equals(attributeName))
+			doLocalVariableTable(in, indent);
+		else if ("InnerClasses".equals(attributeName))
+			doInnerClasses(in, indent);
+		else if ("Exceptions".equals(attributeName))
+			doExceptions(in, indent);
+		else if ("EnclosingMethod".equals(attributeName))
+			doEnclosingMethod(in, indent);
+		else if ("Signature".equals(attributeName))
+			doSignature(in, indent);
+		else if ("Synthetic".equals(attributeName))
+			; // Is empty!
+		else if ("Deprecated".equals(attributeName))
+			; // Is Empty
+		else {
+			ps.printf("%-30s %d\n", indent + "Unknown attribute, skipping", attribute_length);
+			if (attribute_length > 0x7FFFFFFF) {
+				throw new IllegalArgumentException("Attribute > 2Gb");
+			}
+			byte buffer[] = new byte[(int) attribute_length];
+			in.readFully(buffer);
+			printHex(buffer);
+		}
+	}
 
-    /**
-     * <pre>
-     * EnclosingMethod_attribute {
-     * 	u2 attribute_name_index;
-     * 	u4 attribute_length;
-     * 	u2 class_index
-     * 	u2 method_index;
-     * 	}
-     * 	
-     * </pre>
-     */
-    void doEnclosingMethod(DataInputStream in, String indent)
-            throws IOException {
-        int class_index = in.readUnsignedShort();
-        int method_index = in.readUnsignedShort();
-        ps.printf("%-30s %s(#%d/c) %s\n", //
-        		indent + "enclosing method", //
-                pool[((Integer) pool[class_index]).intValue()], //
-                class_index, //
-                (method_index == 0 ? "<>" : pool[method_index]));
-    }
+	/**
+	 * <pre>
+	 * Signature_attribute {
+	 * 	u2 attribute_name_index;
+	 * 	u4 attribute_length;
+	 * 	u2 signature_index;
+	 * 	}
+	 * </pre>
+	 * 
+	 * @param in
+	 * @param indent
+	 */
+	void doSignature(DataInputStream in, String indent) throws IOException {
+		int signature_index = in.readUnsignedShort();
+		ps.printf("%-30s %s(#%d)\n", indent + "signature", pool[signature_index], signature_index);
+	}
 
-    /**
-     * <pre>
-     *  Exceptions_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 number_of_exceptions;
-     * 		u2 exception_index_table[number_of_exceptions];
-     * 	}
-     * </pre>
-     * 
-     * @param in
-     * @param indent
-     */
-    private void doExceptions(DataInputStream in, String indent)
-            throws IOException {
-        int number_of_exceptions = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "number of exceptions",
-                number_of_exceptions);
-        StringBuilder sb = new StringBuilder();
-        String del = "";
-        for (int i = 0; i < number_of_exceptions; i++) {
-            int exception_index_table = in.readUnsignedShort();
-            sb.append(del);
-            sb.append(pool[((Integer) pool[exception_index_table])]);
-            sb.append("(#");
-            sb.append(exception_index_table);
-            sb.append("/c)");
-            del = ", ";
-        }
-        ps.printf("%-30s %d: %s\n", indent + "exceptions",
-                number_of_exceptions, sb);
-    }
+	/**
+	 * <pre>
+	 * EnclosingMethod_attribute {
+	 * 	u2 attribute_name_index;
+	 * 	u4 attribute_length;
+	 * 	u2 class_index
+	 * 	u2 method_index;
+	 * 	}
+	 * 
+	 * </pre>
+	 */
+	void doEnclosingMethod(DataInputStream in, String indent) throws IOException {
+		int class_index = in.readUnsignedShort();
+		int method_index = in.readUnsignedShort();
+		ps.printf("%-30s %s(#%d/c) %s\n", //
+				indent + "enclosing method", //
+				pool[((Integer) pool[class_index]).intValue()], //
+				class_index, //
+				(method_index == 0 ? "<>" : pool[method_index]));
+	}
 
-    /**
-     * <pre>
-     * Code_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 max_stack;
-     * 		u2 max_locals;
-     * 		u4 code_length;
-     * 		u1 code[code_length];
-     * 		u2 exception_table_length;
-     * 		{    	u2 start_pc;
-     * 		      	u2 end_pc;
-     * 		      	u2  handler_pc;
-     * 		      	u2  catch_type;
-     * 		}	exception_table[exception_table_length];
-     * 		u2 attributes_count;
-     * 		attribute_info attributes[attributes_count];
-     * 	}
-     * </pre>
-     * 
-     * @param in
-     * @param pool
-     * @throws IOException
-     */
-    private void doCode(DataInputStream in, String indent) throws IOException {
-        int max_stack = in.readUnsignedShort();
-        int max_locals = in.readUnsignedShort();
-        int code_length = in.readInt();
-        ps.printf(NUM_COLUMN, indent + "max_stack", max_stack);
-        ps.printf(NUM_COLUMN, indent + "max_locals", max_locals);
-        ps.printf(NUM_COLUMN, indent + "code_length", code_length);
-        byte code[] = new byte[code_length];
-        in.readFully(code);
-        printHex(code);
-        int exception_table_length = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "exception_table_length",
-                exception_table_length);
+	/**
+	 * <pre>
+	 *  Exceptions_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 number_of_exceptions;
+	 * 		u2 exception_index_table[number_of_exceptions];
+	 * 	}
+	 * </pre>
+	 * 
+	 * @param in
+	 * @param indent
+	 */
+	private void doExceptions(DataInputStream in, String indent) throws IOException {
+		int number_of_exceptions = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "number of exceptions", number_of_exceptions);
+		StringBuilder sb = new StringBuilder();
+		String del = "";
+		for (int i = 0; i < number_of_exceptions; i++) {
+			int exception_index_table = in.readUnsignedShort();
+			sb.append(del);
+			sb.append(pool[((Integer) pool[exception_index_table])]);
+			sb.append("(#");
+			sb.append(exception_index_table);
+			sb.append("/c)");
+			del = ", ";
+		}
+		ps.printf("%-30s %d: %s\n", indent + "exceptions", number_of_exceptions, sb);
+	}
 
-        for (int i = 0; i < exception_table_length; i++) {
-            int start_pc = in.readUnsignedShort();
-            int end_pc = in.readUnsignedShort();
-            int handler_pc = in.readUnsignedShort();
-            int catch_type = in.readUnsignedShort();
-            ps.printf("%-30s %d/%d/%d/%d\n", indent + "exception_table",
-                    start_pc, end_pc, handler_pc, catch_type);
-        }
-        doAttributes(in, indent + "  ");
-    }
+	/**
+	 * <pre>
+	 * Code_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 max_stack;
+	 * 		u2 max_locals;
+	 * 		u4 code_length;
+	 * 		u1 code[code_length];
+	 * 		u2 exception_table_length;
+	 * 		{    	u2 start_pc;
+	 * 		      	u2 end_pc;
+	 * 		      	u2  handler_pc;
+	 * 		      	u2  catch_type;
+	 * 		}	exception_table[exception_table_length];
+	 * 		u2 attributes_count;
+	 * 		attribute_info attributes[attributes_count];
+	 * 	}
+	 * </pre>
+	 * 
+	 * @param in
+	 * @param pool
+	 * @throws IOException
+	 */
+	private void doCode(DataInputStream in, String indent) throws IOException {
+		int max_stack = in.readUnsignedShort();
+		int max_locals = in.readUnsignedShort();
+		int code_length = in.readInt();
+		ps.printf(NUM_COLUMN, indent + "max_stack", max_stack);
+		ps.printf(NUM_COLUMN, indent + "max_locals", max_locals);
+		ps.printf(NUM_COLUMN, indent + "code_length", code_length);
+		byte code[] = new byte[code_length];
+		in.readFully(code);
+		printHex(code);
+		int exception_table_length = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "exception_table_length", exception_table_length);
 
-    /**
-     * We must find Class.forName references ...
-     * 
-     * @param code
-     */
-    protected void printHex(byte[] code) {
-        int index = 0;
-        while (index < code.length) {
-            StringBuilder sb = new StringBuilder();
-            for (int i = 0; i < 16 && index < code.length; i++) {
-                String s = Integer.toHexString((0xFF & code[index++]))
-                        .toUpperCase();
-                if (s.length() == 1)
-                    sb.append("0");
-                sb.append(s);
-                sb.append(" ");
-            }
-            ps.printf(STR_COLUMN, "", sb.toString());
-        }
-    }
+		for (int i = 0; i < exception_table_length; i++) {
+			int start_pc = in.readUnsignedShort();
+			int end_pc = in.readUnsignedShort();
+			int handler_pc = in.readUnsignedShort();
+			int catch_type = in.readUnsignedShort();
+			ps.printf("%-30s %d/%d/%d/%d\n", indent + "exception_table", start_pc, end_pc, handler_pc, catch_type);
+		}
+		doAttributes(in, indent + "  ");
+	}
 
-    private void doSourceFile(DataInputStream in, String indent)
-            throws IOException {
-        int sourcefile_index = in.readUnsignedShort();
-        ps.printf("%-30s %s(#%d)\n", indent + "Source file",
-                pool[sourcefile_index], sourcefile_index);
-    }
+	/**
+	 * We must find Class.forName references ...
+	 * 
+	 * @param code
+	 */
+	protected void printHex(byte[] code) {
+		int index = 0;
+		while (index < code.length) {
+			StringBuilder sb = new StringBuilder();
+			for (int i = 0; i < 16 && index < code.length; i++) {
+				String s = Integer.toHexString((0xFF & code[index++])).toUpperCase();
+				if (s.length() == 1)
+					sb.append("0");
+				sb.append(s);
+				sb.append(" ");
+			}
+			ps.printf(STR_COLUMN, "", sb.toString());
+		}
+	}
 
-    private void doAnnotations(DataInputStream in, String indent)
-            throws IOException {
-        int num_annotations = in.readUnsignedShort(); // # of annotations
-        ps
-                .printf(NUM_COLUMN, indent + "Number of annotations",
-                        num_annotations);
-        for (int a = 0; a < num_annotations; a++) {
-            doAnnotation(in, indent);
-        }
-    }
+	private void doSourceFile(DataInputStream in, String indent) throws IOException {
+		int sourcefile_index = in.readUnsignedShort();
+		ps.printf("%-30s %s(#%d)\n", indent + "Source file", pool[sourcefile_index], sourcefile_index);
+	}
 
-    private void doAnnotation(DataInputStream in, String indent)
-            throws IOException {
-        int type_index = in.readUnsignedShort();
-        ps.printf("%-30s %s(#%d)", indent + "type", pool[type_index],
-                type_index);
-        int num_element_value_pairs = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "num_element_value_pairs",
-                num_element_value_pairs);
-        for (int v = 0; v < num_element_value_pairs; v++) {
-            int element_name_index = in.readUnsignedShort();
-            ps.printf(NUM_COLUMN, indent + "element_name_index",
-                    element_name_index);
-            doElementValue(in, indent);
-        }
-    }
+	private void doAnnotations(DataInputStream in, String indent) throws IOException {
+		int num_annotations = in.readUnsignedShort(); // # of annotations
+		ps.printf(NUM_COLUMN, indent + "Number of annotations", num_annotations);
+		for (int a = 0; a < num_annotations; a++) {
+			doAnnotation(in, indent);
+		}
+	}
 
-    private void doElementValue(DataInputStream in, String indent)
-            throws IOException {
-        int tag = in.readUnsignedByte();
-        switch (tag) {
-        case 'B':
-        case 'C':
-        case 'D':
-        case 'F':
-        case 'I':
-        case 'J':
-        case 'S':
-        case 'Z':
-        case 's':
-            int const_value_index = in.readUnsignedShort();
-            ps.printf("%-30s %c %s(#%d)\n", indent + "element value", tag,
-                    pool[const_value_index], const_value_index);
-            break;
+	private void doAnnotation(DataInputStream in, String indent) throws IOException {
+		int type_index = in.readUnsignedShort();
+		ps.printf("%-30s %s(#%d)", indent + "type", pool[type_index], type_index);
+		int num_element_value_pairs = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "num_element_value_pairs", num_element_value_pairs);
+		for (int v = 0; v < num_element_value_pairs; v++) {
+			int element_name_index = in.readUnsignedShort();
+			ps.printf(NUM_COLUMN, indent + "element_name_index", element_name_index);
+			doElementValue(in, indent);
+		}
+	}
 
-        case 'e':
-            int type_name_index = in.readUnsignedShort();
-            int const_name_index = in.readUnsignedShort();
-            ps.printf("%-30s %c %s(#%d) %s(#%d)\n", indent + "type+const", tag,
-                    pool[type_name_index], type_name_index,
-                    pool[const_name_index], const_name_index);
-            break;
+	private void doElementValue(DataInputStream in, String indent) throws IOException {
+		int tag = in.readUnsignedByte();
+		switch (tag) {
+			case 'B' :
+			case 'C' :
+			case 'D' :
+			case 'F' :
+			case 'I' :
+			case 'J' :
+			case 'S' :
+			case 'Z' :
+			case 's' :
+				int const_value_index = in.readUnsignedShort();
+				ps.printf("%-30s %c %s(#%d)\n", indent + "element value", tag, pool[const_value_index],
+						const_value_index);
+				break;
 
-        case 'c':
-            int class_info_index = in.readUnsignedShort();
-            ps.printf("%-30s %c %s(#%d)\n", indent + "element value", tag,
-                    pool[class_info_index], class_info_index);
-            break;
+			case 'e' :
+				int type_name_index = in.readUnsignedShort();
+				int const_name_index = in.readUnsignedShort();
+				ps.printf("%-30s %c %s(#%d) %s(#%d)\n", indent + "type+const", tag, pool[type_name_index],
+						type_name_index, pool[const_name_index], const_name_index);
+				break;
 
-        case '@':
-            ps.printf("%-30s %c\n", indent + "sub annotation", tag);
-            doAnnotation(in, indent);
-            break;
+			case 'c' :
+				int class_info_index = in.readUnsignedShort();
+				ps.printf("%-30s %c %s(#%d)\n", indent + "element value", tag, pool[class_info_index], class_info_index);
+				break;
 
-        case '[':
-            int num_values = in.readUnsignedShort();
-            ps.printf("%-30s %c num_values=%d\n", indent + "sub element value",
-                    tag, num_values);
-            for (int i = 0; i < num_values; i++) {
-                doElementValue(in, indent);
-            }
-            break;
+			case '@' :
+				ps.printf("%-30s %c\n", indent + "sub annotation", tag);
+				doAnnotation(in, indent);
+				break;
 
-        default:
-            throw new IllegalArgumentException(
-                    "Invalid value for Annotation ElementValue tag " + tag);
-        }
-    }
+			case '[' :
+				int num_values = in.readUnsignedShort();
+				ps.printf("%-30s %c num_values=%d\n", indent + "sub element value", tag, num_values);
+				for (int i = 0; i < num_values; i++) {
+					doElementValue(in, indent);
+				}
+				break;
 
-    /**
-     * <pre>
-     *  LineNumberTable_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 line_number_table_length;
-     * 		{  u2 start_pc;	     
-     * 		   u2 line_number;	     
-     * 		} line_number_table[line_number_table_length];
-     * 	}
-     * 	
-     * </pre>
-     */
-    void doLineNumberTable(DataInputStream in, String indent)
-            throws IOException {
-        int line_number_table_length = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "line number table length",
-                line_number_table_length);
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < line_number_table_length; i++) {
-            int start_pc = in.readUnsignedShort();
-            int line_number = in.readUnsignedShort();
-            sb.append(start_pc);
-            sb.append("/");
-            sb.append(line_number);
-            sb.append(" ");
-        }
-        ps.printf("%-30s %d: %s\n", indent + "line number table",
-                line_number_table_length, sb);
-    }
+			default :
+				throw new IllegalArgumentException("Invalid value for Annotation ElementValue tag " + tag);
+		}
+	}
 
-    /**
-     * 
-     * <pre>
-     * 	LocalVariableTable_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 local_variable_table_length;
-     * 		{  u2 start_pc;
-     * 		    u2 length;
-     * 		    u2 name_index;
-     * 		    u2 descriptor_index;
-     * 		    u2 index;
-     * 		} local_variable_table[local_variable_table_length];
-     * 	}	
-     * </pre>
-     */
+	/**
+	 * <pre>
+	 *  LineNumberTable_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 line_number_table_length;
+	 * 		{  u2 start_pc;	     
+	 * 		   u2 line_number;	     
+	 * 		} line_number_table[line_number_table_length];
+	 * 	}
+	 * 
+	 * </pre>
+	 */
+	void doLineNumberTable(DataInputStream in, String indent) throws IOException {
+		int line_number_table_length = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "line number table length", line_number_table_length);
+		StringBuilder sb = new StringBuilder();
+		for (int i = 0; i < line_number_table_length; i++) {
+			int start_pc = in.readUnsignedShort();
+			int line_number = in.readUnsignedShort();
+			sb.append(start_pc);
+			sb.append("/");
+			sb.append(line_number);
+			sb.append(" ");
+		}
+		ps.printf("%-30s %d: %s\n", indent + "line number table", line_number_table_length, sb);
+	}
 
-    void doLocalVariableTable(DataInputStream in, String indent)
-            throws IOException {
-        int local_variable_table_length = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "local variable table length",
-                local_variable_table_length);
-        for (int i = 0; i < local_variable_table_length; i++) {
-            int start_pc = in.readUnsignedShort();
-            int length = in.readUnsignedShort();
-            int name_index = in.readUnsignedShort();
-            int descriptor_index = in.readUnsignedShort();
-            int index = in.readUnsignedShort();
-            ps.printf("%-30s %d: %d/%d %s(#%d) %s(#%d)\n", indent, index,
-                    start_pc, length, pool[name_index], name_index,
-                    pool[descriptor_index], descriptor_index);
-        }
-    }
+	/**
+	 * <pre>
+	 * 	LocalVariableTable_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 local_variable_table_length;
+	 * 		{  u2 start_pc;
+	 * 		    u2 length;
+	 * 		    u2 name_index;
+	 * 		    u2 descriptor_index;
+	 * 		    u2 index;
+	 * 		} local_variable_table[local_variable_table_length];
+	 * 	}
+	 * </pre>
+	 */
 
-    /**
-     * <pre>
-     *    InnerClasses_attribute {
-     * 		u2 attribute_name_index;
-     * 		u4 attribute_length;
-     * 		u2 number_of_classes;
-     * 		{  u2 inner_class_info_index;	     
-     * 		   u2 outer_class_info_index;	     
-     * 		   u2 inner_name_index;	     
-     * 		   u2 inner_class_access_flags;	     
-     * 		} classes[number_of_classes];
-     * 	}
-     * </pre>
-     * 
-     */
-    void doInnerClasses(DataInputStream in, String indent) throws IOException {
-        int number_of_classes = in.readUnsignedShort();
-        ps.printf(NUM_COLUMN, indent + "number of classes", number_of_classes);
-        for (int i = 0; i < number_of_classes; i++) {
-            int inner_class_info_index = in.readUnsignedShort();
-            int outer_class_info_index = in.readUnsignedShort();
-            int inner_name_index = in.readUnsignedShort();
-            int inner_class_access_flags = in.readUnsignedShort();
-            printAccess(inner_class_access_flags);
+	void doLocalVariableTable(DataInputStream in, String indent) throws IOException {
+		int local_variable_table_length = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "local variable table length", local_variable_table_length);
+		for (int i = 0; i < local_variable_table_length; i++) {
+			int start_pc = in.readUnsignedShort();
+			int length = in.readUnsignedShort();
+			int name_index = in.readUnsignedShort();
+			int descriptor_index = in.readUnsignedShort();
+			int index = in.readUnsignedShort();
+			ps.printf("%-30s %d: %d/%d %s(#%d) %s(#%d)\n", indent, index, start_pc, length, pool[name_index],
+					name_index, pool[descriptor_index], descriptor_index);
+		}
+	}
 
-            String iname = "<>";
-            String oname = iname;
+	/**
+	 * <pre>
+	 *    InnerClasses_attribute {
+	 * 		u2 attribute_name_index;
+	 * 		u4 attribute_length;
+	 * 		u2 number_of_classes;
+	 * 		{  u2 inner_class_info_index;	     
+	 * 		   u2 outer_class_info_index;	     
+	 * 		   u2 inner_name_index;	     
+	 * 		   u2 inner_class_access_flags;	     
+	 * 		} classes[number_of_classes];
+	 * 	}
+	 * </pre>
+	 */
+	void doInnerClasses(DataInputStream in, String indent) throws IOException {
+		int number_of_classes = in.readUnsignedShort();
+		ps.printf(NUM_COLUMN, indent + "number of classes", number_of_classes);
+		for (int i = 0; i < number_of_classes; i++) {
+			int inner_class_info_index = in.readUnsignedShort();
+			int outer_class_info_index = in.readUnsignedShort();
+			int inner_name_index = in.readUnsignedShort();
+			int inner_class_access_flags = in.readUnsignedShort();
+			printAccess(inner_class_access_flags);
 
-            if (inner_class_info_index != 0)
-                iname = (String) pool[((Integer) pool[inner_class_info_index])
-                        .intValue()];
-            if (outer_class_info_index != 0)
-                oname = (String) pool[((Integer) pool[outer_class_info_index])
-                        .intValue()];
+			String iname = "<>";
+			String oname = iname;
 
-            ps.printf("%-30s %d: %x %s(#%d/c) %s(#%d/c) %s(#%d) \n", indent, i,
-                    inner_class_access_flags, iname, inner_class_info_index,
-                    oname, outer_class_info_index, pool[inner_name_index],
-                    inner_name_index);
-        }
-    }
+			if (inner_class_info_index != 0)
+				iname = (String) pool[((Integer) pool[inner_class_info_index]).intValue()];
+			if (outer_class_info_index != 0)
+				oname = (String) pool[((Integer) pool[outer_class_info_index]).intValue()];
 
+			ps.printf("%-30s %d: %x %s(#%d/c) %s(#%d/c) %s(#%d) \n", indent, i, inner_class_access_flags, iname,
+					inner_class_info_index, oname, outer_class_info_index, pool[inner_name_index], inner_name_index);
+		}
+	}
 
-    void printClassAccess(int mod) {
-        ps.printf("%-30s", "Class Access");
-        if ((ACC_PUBLIC&mod)!= 0)
-            ps.print(" public");
-        if ((ACC_FINAL&mod)!= 0)
-            ps.print(" final");
-        if ((ACC_SUPER&mod)!= 0)
-            ps.print(" super");
-        if ((ACC_INTERFACE&mod)!= 0)
-            ps.print(" interface");
-        if ((ACC_ABSTRACT&mod)!= 0)
-            ps.print(" abstract");
+	void printClassAccess(int mod) {
+		ps.printf("%-30s", "Class Access");
+		if ((ACC_PUBLIC & mod) != 0)
+			ps.print(" public");
+		if ((ACC_FINAL & mod) != 0)
+			ps.print(" final");
+		if ((ACC_SUPER & mod) != 0)
+			ps.print(" super");
+		if ((ACC_INTERFACE & mod) != 0)
+			ps.print(" interface");
+		if ((ACC_ABSTRACT & mod) != 0)
+			ps.print(" abstract");
 
-        ps.println();
-    }
+		ps.println();
+	}
 
-    void printAccess(int mod) {
-        ps.printf("%-30s", "Access");
-        if (Modifier.isStatic(mod))
-            ps.print(" static");
-        if (Modifier.isAbstract(mod))
-            ps.print(" abstract");
-        if (Modifier.isPublic(mod))
-            ps.print(" public");
-        if (Modifier.isFinal(mod))
-            ps.print(" final");
-        if (Modifier.isInterface(mod))
-            ps.print(" interface");
-        if (Modifier.isNative(mod))
-            ps.print(" native");
-        if (Modifier.isPrivate(mod))
-            ps.print(" private");
-        if (Modifier.isProtected(mod))
-            ps.print(" protected");
-        if (Modifier.isStrict(mod))
-            ps.print(" strict");
-        if (Modifier.isSynchronized(mod))
-            ps.print(" synchronized");
-        if (Modifier.isTransient(mod))
-            ps.print(" transient");
-        if (Modifier.isVolatile(mod))
-            ps.print(" volatile");
+	void printAccess(int mod) {
+		ps.printf("%-30s", "Access");
+		if (Modifier.isStatic(mod))
+			ps.print(" static");
+		if (Modifier.isAbstract(mod))
+			ps.print(" abstract");
+		if (Modifier.isPublic(mod))
+			ps.print(" public");
+		if (Modifier.isFinal(mod))
+			ps.print(" final");
+		if (Modifier.isInterface(mod))
+			ps.print(" interface");
+		if (Modifier.isNative(mod))
+			ps.print(" native");
+		if (Modifier.isPrivate(mod))
+			ps.print(" private");
+		if (Modifier.isProtected(mod))
+			ps.print(" protected");
+		if (Modifier.isStrict(mod))
+			ps.print(" strict");
+		if (Modifier.isSynchronized(mod))
+			ps.print(" synchronized");
+		if (Modifier.isTransient(mod))
+			ps.print(" transient");
+		if (Modifier.isVolatile(mod))
+			ps.print(" volatile");
 
-        ps.println();
-    }
+		ps.println();
+	}
 
-    public static void main(String args[]) throws Exception {
-        if (args.length == 0) {
-            System.err.println("clsd <class file>+");
-        }
-        for (int i = 0; i < args.length; i++) {
-            File f = new File(args[i]);
-            if (!f.isFile())
-                System.err.println("File does not exist or is directory " + f);
-            else {
-                ClassDumper cd = new ClassDumper(args[i]);
-                cd.dump(null);
-            }
-        }
-    }
+	public static void main(String args[]) throws Exception {
+		if (args.length == 0) {
+			System.err.println("clsd <class file>+");
+		}
+		for (int i = 0; i < args.length; i++) {
+			File f = new File(args[i]);
+			if (!f.isFile())
+				System.err.println("File does not exist or is directory " + f);
+			else {
+				ClassDumper cd = new ClassDumper(args[i]);
+				cd.dump(null);
+			}
+		}
+	}
 
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/classloaders/URLClassLoaderWrapper.java b/bundleplugin/src/main/java/aQute/libg/classloaders/URLClassLoaderWrapper.java
index 10ddca5..c199a92 100644
--- a/bundleplugin/src/main/java/aQute/libg/classloaders/URLClassLoaderWrapper.java
+++ b/bundleplugin/src/main/java/aQute/libg/classloaders/URLClassLoaderWrapper.java
@@ -4,24 +4,25 @@
 import java.net.*;
 
 public class URLClassLoaderWrapper {
-	final URLClassLoader loader;
-	final Method addURL;
-	
+	final URLClassLoader	loader;
+	final Method			addURL;
+
 	public URLClassLoaderWrapper(ClassLoader loader) throws Exception {
 		this.loader = (URLClassLoader) loader;
 		addURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
 		addURL.setAccessible(true);
 	}
-	
-	public void addURL(URL url) throws Exception  {
+
+	public void addURL(URL url) throws Exception {
 		try {
-		addURL.invoke(loader, url);
-		} catch( InvocationTargetException ite) {
+			addURL.invoke(loader, url);
+		}
+		catch (InvocationTargetException ite) {
 			throw (Exception) ite.getTargetException();
 		}
 	}
-	
-	public Class<?> loadClass(String name) throws Exception {
+
+	public Class< ? > loadClass(String name) throws Exception {
 		return loader.loadClass(name);
 	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/clauses/Clauses.java b/bundleplugin/src/main/java/aQute/libg/clauses/Clauses.java
index 12eba4f..5701bab 100755
--- a/bundleplugin/src/main/java/aQute/libg/clauses/Clauses.java
+++ b/bundleplugin/src/main/java/aQute/libg/clauses/Clauses.java
@@ -5,15 +5,14 @@
 import aQute.libg.log.*;
 import aQute.libg.qtokens.*;
 
-public class Clauses extends LinkedHashMap<String,Map<String,String>>{
+public class Clauses extends LinkedHashMap<String,Map<String,String>> {
 	private static final long	serialVersionUID	= 1L;
-	
+
 	/**
 	 * Standard OSGi header parser. This parser can handle the format clauses
 	 * ::= clause ( ',' clause ) + clause ::= name ( ';' name ) (';' key '='
-	 * value )
-	 * 
-	 * This is mapped to a Map { name => Map { attr|directive => value } }
+	 * value ) This is mapped to a Map { name => Map { attr|directive => value }
+	 * }
 	 * 
 	 * @param value
 	 * @return
@@ -36,9 +35,8 @@
 				String adname = qt.nextToken();
 				if ((del = qt.getSeparator()) != '=') {
 					if (hadAttribute)
-						throw new IllegalArgumentException(
-								"Header contains name field after attribute or directive: "
-										+ adname + " from " + value);
+						throw new IllegalArgumentException("Header contains name field after attribute or directive: "
+								+ adname + " from " + value);
 					aliases.add(adname);
 				} else {
 					String advalue = qt.nextToken();
@@ -51,10 +49,8 @@
 				String packageName = i.next();
 				if (result.containsKey(packageName)) {
 					if (logger != null)
-						logger
-								.warning("Duplicate package name in header: "
-										+ packageName
-										+ ". Multiple package names in one clause not supported in Bnd.");
+						logger.warning("Duplicate package name in header: " + packageName
+								+ ". Multiple package names in one clause not supported in Bnd.");
 				} else
 					result.put(packageName, clause);
 			}
diff --git a/bundleplugin/src/main/java/aQute/libg/clauses/Selector.java b/bundleplugin/src/main/java/aQute/libg/clauses/Selector.java
index eaa806c..a2a9699 100755
--- a/bundleplugin/src/main/java/aQute/libg/clauses/Selector.java
+++ b/bundleplugin/src/main/java/aQute/libg/clauses/Selector.java
@@ -65,18 +65,18 @@
 		StringBuilder sb = new StringBuilder();
 		for (int c = 0; c < string.length(); c++) {
 			switch (string.charAt(c)) {
-			case '.':
-				sb.append("\\.");
-				break;
-			case '*':
-				sb.append(".*");
-				break;
-			case '?':
-				sb.append(".?");
-				break;
-			default:
-				sb.append(string.charAt(c));
-				break;
+				case '.' :
+					sb.append("\\.");
+					break;
+				case '*' :
+					sb.append(".*");
+					break;
+				case '?' :
+					sb.append(".?");
+					break;
+				default :
+					sb.append(string.charAt(c));
+					break;
 			}
 		}
 		string = sb.toString();
@@ -101,17 +101,16 @@
 
 	public static List<Selector> getInstructions(Clauses clauses) {
 		List<Selector> result = new ArrayList<Selector>();
-		for (Map.Entry<String, Map<String, String>> entry : clauses.entrySet()) {
+		for (Map.Entry<String,Map<String,String>> entry : clauses.entrySet()) {
 			Selector instruction = getPattern(entry.getKey());
 			result.add(instruction);
 		}
 		return result;
 	}
-	
-	public static <T> List<T> select(Collection<T> domain,
-			List<Selector> instructions) {
+
+	public static <T> List<T> select(Collection<T> domain, List<Selector> instructions) {
 		List<T> result = new ArrayList<T>();
-		Iterator<T> iterator = domain.iterator(); 
+		Iterator<T> iterator = domain.iterator();
 		value: while (iterator.hasNext()) {
 			T value = iterator.next();
 			for (Selector instruction : instructions) {
@@ -124,6 +123,5 @@
 		}
 		return result;
 	}
-	
 
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/command/Command.java b/bundleplugin/src/main/java/aQute/libg/command/Command.java
index 209be52..3feb702 100644
--- a/bundleplugin/src/main/java/aQute/libg/command/Command.java
+++ b/bundleplugin/src/main/java/aQute/libg/command/Command.java
@@ -12,7 +12,7 @@
 	boolean				trace;
 	Reporter			reporter;
 	List<String>		arguments	= new ArrayList<String>();
-	Map<String, String>	variables	= new LinkedHashMap<String, String>();
+	Map<String,String>	variables	= new LinkedHashMap<String,String>();
 	long				timeout		= 0;
 	File				cwd			= new File("").getAbsoluteFile();
 	static Timer		timer		= new Timer(Command.class.getName(), true);
@@ -24,8 +24,7 @@
 		this.fullCommand = fullCommand;
 	}
 
-	public Command() {
-	}
+	public Command() {}
 
 	public int execute(Appendable stdout, Appendable stderr) throws Exception {
 		return execute((InputStream) null, stdout, stderr);
@@ -44,7 +43,7 @@
 		String args[] = arguments.toArray(new String[arguments.size()]);
 		String vars[] = new String[variables.size()];
 		int i = 0;
-		for (Entry<String, String> s : variables.entrySet()) {
+		for (Entry<String,String> s : variables.entrySet()) {
 			vars[i++] = s.getKey() + "=" + s.getValue();
 		}
 
@@ -53,7 +52,6 @@
 		else
 			process = Runtime.getRuntime().exec(fullCommand, vars.length == 0 ? null : vars, cwd);
 
-		
 		// Make sure the command will not linger when we go
 		Runnable r = new Runnable() {
 			public void run() {
@@ -83,12 +81,12 @@
 				cout.start();
 				Collector cerr = new Collector(err, stderr);
 				cerr.start();
-	
+
 				try {
 					int c = in.read();
 					while (c >= 0) {
 						stdin.write(c);
-						if ( c == '\n')
+						if (c == '\n')
 							stdin.flush();
 						c = in.read();
 					}
@@ -98,13 +96,14 @@
 				}
 				catch (Exception e) {
 					// Who cares?
-				} finally {
+				}
+				finally {
 					stdin.close();
 				}
-				
+
 				if (reporter != null)
 					reporter.trace("exited process");
-				
+
 				cerr.join();
 				cout.join();
 				if (reporter != null)
@@ -120,15 +119,15 @@
 				timer.cancel();
 			Runtime.getRuntime().removeShutdownHook(hook);
 		}
-		
+
 		byte exitValue = (byte) process.waitFor();
 		if (reporter != null)
-			reporter.trace("cmd %s executed with result=%d, result: %s/%s, timedout=%s", arguments, exitValue,
-					stdout, stderr, timedout);
+			reporter.trace("cmd %s executed with result=%d, result: %s/%s, timedout=%s", arguments, exitValue, stdout,
+					stderr, timedout);
 
 		if (timedout)
 			return Integer.MIN_VALUE;
-		
+
 		return exitValue;
 	}
 
@@ -182,7 +181,7 @@
 					c = in.read();
 				}
 			}
-			catch( IOException e) {
+			catch (IOException e) {
 				// We assume the socket is closed
 			}
 			catch (Exception e) {
@@ -191,8 +190,7 @@
 					sb.append(e.toString());
 					sb.append("\n**************************************\n");
 				}
-				catch (IOException e1) {
-				}
+				catch (IOException e1) {}
 				if (reporter != null) {
 					reporter.trace("cmd exec: %s", e);
 				}
@@ -217,7 +215,7 @@
 
 	public void inherit() {
 		ProcessBuilder pb = new ProcessBuilder();
-		for (Entry<String, String> e : pb.environment().entrySet()) {
+		for (Entry<String,String> e : pb.environment().entrySet()) {
 			var(e.getKey(), e.getValue());
 		}
 	}
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Crypto.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Crypto.java
index ff971e8..22eac45 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/Crypto.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Crypto.java
@@ -7,61 +7,57 @@
 import java.util.regex.*;
 
 public class Crypto {
-	static final Pattern	RSA_PRIVATE	= Pattern
-												.compile("\\s*RSA\\.Private\\((\\p{XDigit})+:(\\p{XDigit})+\\)\\s*");
-	static final Pattern	RSA_PUBLIC	= Pattern
-												.compile("\\s*RSA\\.Public\\((\\p{XDigit})+:(\\p{XDigit})+\\)\\s*");
+	static final Pattern	RSA_PRIVATE	= Pattern.compile("\\s*RSA\\.Private\\((\\p{XDigit})+:(\\p{XDigit})+\\)\\s*");
+	static final Pattern	RSA_PUBLIC	= Pattern.compile("\\s*RSA\\.Public\\((\\p{XDigit})+:(\\p{XDigit})+\\)\\s*");
 
 	/**
-	 * 
 	 * @param <T>
 	 * @param spec
 	 * @return
 	 * @throws Exception
 	 */
-	@SuppressWarnings("unchecked") public static <T> T fromString(String spec, Class<T> c) throws Exception {
-		if ( PrivateKey.class.isAssignableFrom(c)) {
-			Matcher m = RSA_PRIVATE.matcher(spec); 
-			if ( m.matches()) {
-				return (T) RSA.createPrivate(  
-						new BigInteger(m.group(1)), new BigInteger(m.group(2)));
+	@SuppressWarnings("unchecked")
+	public static <T> T fromString(String spec, Class<T> c) throws Exception {
+		if (PrivateKey.class.isAssignableFrom(c)) {
+			Matcher m = RSA_PRIVATE.matcher(spec);
+			if (m.matches()) {
+				return (T) RSA.createPrivate(new BigInteger(m.group(1)), new BigInteger(m.group(2)));
 			}
-			throw new IllegalArgumentException("No such private key " + spec );
+			throw new IllegalArgumentException("No such private key " + spec);
 		}
-		
-		if ( PublicKey.class.isAssignableFrom(c)) {
-			Matcher m = RSA_PUBLIC.matcher(spec); 
-			if ( m.matches()) {
-				return (T) RSA.create( new RSAPublicKeySpec( 
-						new BigInteger(m.group(1)), new BigInteger(m.group(2))));
+
+		if (PublicKey.class.isAssignableFrom(c)) {
+			Matcher m = RSA_PUBLIC.matcher(spec);
+			if (m.matches()) {
+				return (T) RSA.create(new RSAPublicKeySpec(new BigInteger(m.group(1)), new BigInteger(m.group(2))));
 			}
-			throw new IllegalArgumentException("No such public key " + spec );			
+			throw new IllegalArgumentException("No such public key " + spec);
 		}
 		return null;
 	}
 
-	public static String toString( Object key ) {
-		if ( key instanceof RSAPrivateKey ) {
+	public static String toString(Object key) {
+		if (key instanceof RSAPrivateKey) {
 			RSAPrivateKey pk = (RSAPrivateKey) key;
 			return "RSA.Private(" + pk.getModulus() + ":" + pk.getPrivateExponent() + ")";
 		}
-		if ( key instanceof RSAPublicKey ) {
+		if (key instanceof RSAPublicKey) {
 			RSAPublicKey pk = (RSAPublicKey) key;
 			return "RSA.Private(" + pk.getModulus() + ":" + pk.getPublicExponent() + ")";
 		}
 		return null;
 	}
 
-
-//	public static <T extends Digest> Signer<T> signer(PrivateKey key, Digester<T> digester) throws NoSuchAlgorithmException {
-//		Signature s = Signature.getInstance(key.getAlgorithm() + "with" + digester.getAlgorithm());
-//		return new Signer<T>(s,digester);
-//	}
+	// public static <T extends Digest> Signer<T> signer(PrivateKey key,
+	// Digester<T> digester) throws NoSuchAlgorithmException {
+	// Signature s = Signature.getInstance(key.getAlgorithm() + "with" +
+	// digester.getAlgorithm());
+	// return new Signer<T>(s,digester);
+	// }
 
 	public static Verifier verifier(PublicKey key, Digest digest) throws NoSuchAlgorithmException {
 		Signature s = Signature.getInstance(key.getAlgorithm() + "with" + digest.getAlgorithm());
-		return new Verifier(s,digest);
+		return new Verifier(s, digest);
 	}
 
-	
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Digest.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Digest.java
index 90e7b1a..93d48ad 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/Digest.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Digest.java
@@ -10,30 +10,28 @@
 	protected Digest(byte[] checksum, int width) {
 		this.digest = checksum;
 		if (digest.length != width)
-			throw new IllegalArgumentException("Invalid width for digest: " + digest.length
-					+ " expected " + width);
+			throw new IllegalArgumentException("Invalid width for digest: " + digest.length + " expected " + width);
 	}
 
-
 	public byte[] digest() {
 		return digest;
 	}
 
-	@Override public String toString() {
+	@Override
+	public String toString() {
 		return String.format("%s(d=%s)", getAlgorithm(), Hex.toHexString(digest));
 	}
 
 	public abstract String getAlgorithm();
-	
-	
+
 	public boolean equals(Object other) {
-		if ( !(other instanceof Digest))
+		if (!(other instanceof Digest))
 			return false;
 
 		Digest d = (Digest) other;
 		return Arrays.equals(d.digest, digest);
 	}
-	
+
 	public int hashCode() {
 		return Arrays.hashCode(digest);
 	}
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
index eeb2c8f..2785c3d 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
@@ -7,41 +7,45 @@
 
 public abstract class Digester<T extends Digest> extends OutputStream {
 	protected MessageDigest	md;
-	OutputStream out[];
-	
-	public Digester(MessageDigest instance, OutputStream ... out) {
+	OutputStream			out[];
+
+	public Digester(MessageDigest instance, OutputStream... out) {
 		md = instance;
 		this.out = out;
 	}
-	
+
 	@Override
-	public void write( byte[] buffer, int offset, int length) throws IOException{
-		md.update(buffer,offset,length);
-		for ( OutputStream o : out ) {
+	public void write(byte[] buffer, int offset, int length) throws IOException {
+		md.update(buffer, offset, length);
+		for (OutputStream o : out) {
 			o.write(buffer, offset, length);
 		}
 	}
+
 	@Override
-	public void write( int b) throws IOException{
+	public void write(int b) throws IOException {
 		md.update((byte) b);
-		for ( OutputStream o : out ) {
+		for (OutputStream o : out) {
 			o.write(b);
 		}
 	}
-	
+
 	public MessageDigest getMessageDigest() throws Exception {
 		return md;
 	}
-	
+
 	public T from(InputStream in) throws Exception {
-		IO.copy(in,this);
+		IO.copy(in, this);
 		return digest();
 	}
-		
-	public void setOutputs(OutputStream ...out) {
+
+	public void setOutputs(OutputStream... out) {
 		this.out = out;
 	}
+
 	public abstract T digest() throws Exception;
-	public abstract T digest( byte [] bytes) throws Exception;
+
+	public abstract T digest(byte[] bytes) throws Exception;
+
 	public abstract String getAlgorithm();
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Key.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Key.java
index 160ec05..f4fc217 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/Key.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Key.java
@@ -1,8 +1,6 @@
 package aQute.libg.cryptography;
 
-
 public abstract class Key implements java.security.Key {
 	private static final long	serialVersionUID	= 1L;
 
-
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java b/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java
index 84b53ee..05a6bdd 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/MD5.java
@@ -3,32 +3,36 @@
 import java.io.*;
 import java.security.*;
 
-
-
 public class MD5 extends Digest {
-	public final static String ALGORITHM = "MD5";
-	
-	public static Digester<MD5> getDigester(OutputStream ... out) throws Exception {
+	public final static String	ALGORITHM	= "MD5";
+
+	public static Digester<MD5> getDigester(OutputStream... out) throws Exception {
 		return new Digester<MD5>(MessageDigest.getInstance(ALGORITHM), out) {
-			
-			@Override public MD5 digest() throws Exception {
+
+			@Override
+			public MD5 digest() throws Exception {
 				return new MD5(md.digest());
 			}
 
-			@Override public MD5 digest(byte[] bytes) {
+			@Override
+			public MD5 digest(byte[] bytes) {
 				return new MD5(bytes);
 			}
-			@Override public String getAlgorithm() {
+
+			@Override
+			public String getAlgorithm() {
 				return ALGORITHM;
 			}
 		};
 	}
-	
-	
+
 	public MD5(byte[] digest) {
-		super(digest,16);
+		super(digest, 16);
 	}
 
-	@Override public String getAlgorithm() { return ALGORITHM; }
+	@Override
+	public String getAlgorithm() {
+		return ALGORITHM;
+	}
 
 }
\ No newline at end of file
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/RSA.java b/bundleplugin/src/main/java/aQute/libg/cryptography/RSA.java
index 61bafb5..c1aa2ee 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/RSA.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/RSA.java
@@ -15,7 +15,8 @@
 	static private KeyFactory getKeyFactory() {
 		try {
 			return KeyFactory.getInstance(ALGORITHM);
-		} catch (Exception e) {
+		}
+		catch (Exception e) {
 			// built in
 		}
 		return null;
@@ -24,20 +25,23 @@
 	public static RSAPrivateKey create(RSAPrivateKeySpec keyspec) throws InvalidKeySpecException {
 		return (RSAPrivateKey) factory.generatePrivate(keyspec);
 	}
+
 	public static RSAPublicKey create(RSAPublicKeySpec keyspec) throws InvalidKeySpecException {
 		return (RSAPublicKey) factory.generatePrivate(keyspec);
 	}
-	
+
 	public static RSAPublicKey createPublic(BigInteger m, BigInteger e) throws InvalidKeySpecException {
-		return create( new RSAPublicKeySpec(m,e));
+		return create(new RSAPublicKeySpec(m, e));
 	}
+
 	public static RSAPrivateKey createPrivate(BigInteger m, BigInteger e) throws InvalidKeySpecException {
-		return create( new RSAPrivateKeySpec(m,e));
+		return create(new RSAPrivateKeySpec(m, e));
 	}
-	
-	public static Pair<RSAPrivateKey, RSAPublicKey> generate() throws NoSuchAlgorithmException {
+
+	public static Pair<RSAPrivateKey,RSAPublicKey> generate() throws NoSuchAlgorithmException {
 		KeyPairGenerator kpg = KeyPairGenerator.getInstance(ALGORITHM);
 		KeyPair keypair = kpg.generateKeyPair();
-		return new Pair<RSAPrivateKey,RSAPublicKey>( (RSAPrivateKey) keypair.getPrivate(), (RSAPublicKey) keypair.getPublic());
+		return new Pair<RSAPrivateKey,RSAPublicKey>((RSAPrivateKey) keypair.getPrivate(),
+				(RSAPublicKey) keypair.getPublic());
 	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java b/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java
index a01f112..d0a486c 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/SHA1.java
@@ -3,33 +3,36 @@
 import java.io.*;
 import java.security.*;
 
-
-
 public class SHA1 extends Digest {
-	public final static String ALGORITHM = "SHA1";
-	
-	
-	public static Digester<SHA1> getDigester(OutputStream ... out  ) throws NoSuchAlgorithmException {
+	public final static String	ALGORITHM	= "SHA1";
+
+	public static Digester<SHA1> getDigester(OutputStream... out) throws NoSuchAlgorithmException {
 		MessageDigest md = MessageDigest.getInstance(ALGORITHM);
 		return new Digester<SHA1>(md, out) {
-			@Override public SHA1 digest() throws Exception {
+			@Override
+			public SHA1 digest() throws Exception {
 				return new SHA1(md.digest());
 			}
 
-			@Override public SHA1 digest(byte[] bytes) {
+			@Override
+			public SHA1 digest(byte[] bytes) {
 				return new SHA1(bytes);
 			}
-			@Override public String getAlgorithm() {
+
+			@Override
+			public String getAlgorithm() {
 				return ALGORITHM;
 			}
 		};
 	}
-	
+
 	public SHA1(byte[] b) {
 		super(b, 20);
 	}
 
-
-	@Override public String getAlgorithm() { return ALGORITHM; }
+	@Override
+	public String getAlgorithm() {
+		return ALGORITHM;
+	}
 
 }
\ No newline at end of file
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java b/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java
index 5b25cf3..b6eeacc 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/SHA256.java
@@ -3,33 +3,36 @@
 import java.io.*;
 import java.security.*;
 
-
-
 public class SHA256 extends Digest {
-	public final static String ALGORITHM = "SHA256";
-	
-	
-	public static Digester<SHA256> getDigester(OutputStream ... out  ) throws NoSuchAlgorithmException {
+	public final static String	ALGORITHM	= "SHA256";
+
+	public static Digester<SHA256> getDigester(OutputStream... out) throws NoSuchAlgorithmException {
 		MessageDigest md = MessageDigest.getInstance(ALGORITHM);
 		return new Digester<SHA256>(md, out) {
-			@Override public SHA256 digest() throws Exception {
+			@Override
+			public SHA256 digest() throws Exception {
 				return new SHA256(md.digest());
 			}
 
-			@Override public SHA256 digest(byte[] bytes) {
+			@Override
+			public SHA256 digest(byte[] bytes) {
 				return new SHA256(bytes);
 			}
-			@Override public String getAlgorithm() {
+
+			@Override
+			public String getAlgorithm() {
 				return ALGORITHM;
 			}
 		};
 	}
-	
+
 	public SHA256(byte[] b) {
 		super(b, 32);
 	}
 
-
-	@Override public String getAlgorithm() { return ALGORITHM; }
+	@Override
+	public String getAlgorithm() {
+		return ALGORITHM;
+	}
 
 }
\ No newline at end of file
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java
index 5218e2d..977eda6 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Signer.java
@@ -5,36 +5,39 @@
 
 public class Signer<D extends Digest> extends OutputStream {
 	Signature	signature;
-	Digester<D> digester;
-	
+	Digester<D>	digester;
+
 	Signer(Signature s, Digester<D> digester) {
 		this.signature = s;
-		this.digester  = digester;
+		this.digester = digester;
 	}
 
-	@Override public void write(byte[] buffer, int offset, int length) throws IOException {
+	@Override
+	public void write(byte[] buffer, int offset, int length) throws IOException {
 		try {
 			signature.update(buffer, offset, length);
 			digester.write(buffer, offset, length);
-		} catch (SignatureException e) {
+		}
+		catch (SignatureException e) {
 			throw new IOException(e.getLocalizedMessage());
 		}
 	}
 
-	@Override public void write(int b) throws IOException {
+	@Override
+	public void write(int b) throws IOException {
 		try {
 			signature.update((byte) b);
 			digester.write(b);
-		} catch (SignatureException e) {
+		}
+		catch (SignatureException e) {
 			throw new IOException(e.getLocalizedMessage());
 		}
 	}
-	
 
 	public Signature signature() throws Exception {
 		return signature;
 	}
-	
+
 	public D digest() throws Exception {
 		return digester.digest();
 	}
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Verifier.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Verifier.java
index 5506ece..1005e0a 100644
--- a/bundleplugin/src/main/java/aQute/libg/cryptography/Verifier.java
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Verifier.java
@@ -3,30 +3,31 @@
 import java.io.*;
 import java.security.*;
 
-
 public class Verifier extends OutputStream {
-	final Signature signature;
-	final Digest d;
-	
+	final Signature	signature;
+	final Digest	d;
+
 	Verifier(Signature s, Digest d) {
 		this.signature = s;
 		this.d = d;
 	}
-	
+
 	@Override
-	public void write( byte[] buffer, int offset, int length) throws IOException {
+	public void write(byte[] buffer, int offset, int length) throws IOException {
 		try {
 			signature.update(buffer, offset, length);
-		} catch (SignatureException e) {
+		}
+		catch (SignatureException e) {
 			throw new IOException(e.getLocalizedMessage());
 		}
 	}
 
 	@Override
-	public void write( int b) throws IOException {
+	public void write(int b) throws IOException {
 		try {
 			signature.update((byte) b);
-		} catch (SignatureException e) {
+		}
+		catch (SignatureException e) {
 			throw new IOException(e.getLocalizedMessage());
 		}
 	}
@@ -34,5 +35,5 @@
 	public boolean verify() throws Exception {
 		return signature.verify(d.digest());
 	}
-	
+
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/fileiterator/FileIterator.java b/bundleplugin/src/main/java/aQute/libg/fileiterator/FileIterator.java
index 7cd73a2..2c988e6 100644
--- a/bundleplugin/src/main/java/aQute/libg/fileiterator/FileIterator.java
+++ b/bundleplugin/src/main/java/aQute/libg/fileiterator/FileIterator.java
@@ -4,40 +4,39 @@
 import java.util.*;
 
 public class FileIterator implements Iterator<File> {
-    File         dir;
-    int          n = 0;
-    FileIterator next;
+	File			dir;
+	int				n	= 0;
+	FileIterator	next;
 
-    public FileIterator(File nxt) {
-        assert nxt.isDirectory();
-        this.dir = nxt;
-    }
+	public FileIterator(File nxt) {
+		assert nxt.isDirectory();
+		this.dir = nxt;
+	}
 
-    public boolean hasNext() {
-        if (next != null)
-            return next.hasNext();
+	public boolean hasNext() {
+		if (next != null)
+			return next.hasNext();
 		return n < dir.list().length;
-    }
+	}
 
-    public File next() {
-        if (next != null) {
-            File answer = next.next();
-            if (!next.hasNext())
-                next = null;
-            return answer;
-        }
+	public File next() {
+		if (next != null) {
+			File answer = next.next();
+			if (!next.hasNext())
+				next = null;
+			return answer;
+		}
 		File nxt = dir.listFiles()[n++];
 		if (nxt.isDirectory()) {
-		    next = new FileIterator(nxt);
-		    return nxt;
+			next = new FileIterator(nxt);
+			return nxt;
 		} else if (nxt.isFile()) {
-		    return nxt;
+			return nxt;
 		} else
-		    throw new IllegalStateException("File disappeared");
-    }
+			throw new IllegalStateException("File disappeared");
+	}
 
-    public void remove() {
-        throw new UnsupportedOperationException(
-                "Cannot remove from a file iterator");
-    }
+	public void remove() {
+		throw new UnsupportedOperationException("Cannot remove from a file iterator");
+	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/filelock/DirectoryLock.java b/bundleplugin/src/main/java/aQute/libg/filelock/DirectoryLock.java
index 6e6b11e..9f82899 100644
--- a/bundleplugin/src/main/java/aQute/libg/filelock/DirectoryLock.java
+++ b/bundleplugin/src/main/java/aQute/libg/filelock/DirectoryLock.java
@@ -3,9 +3,9 @@
 import java.io.*;
 
 public class DirectoryLock {
-	final File						lock;
-	final long						timeout;
-	final public static String LOCKNAME = ".lock";
+	final File					lock;
+	final long					timeout;
+	final public static String	LOCKNAME	= ".lock";
 
 	public DirectoryLock(File directory, long timeout) {
 		this.lock = new File(directory, LOCKNAME);
@@ -13,7 +13,6 @@
 		this.timeout = timeout;
 	}
 
-	
 	public void release() {
 		lock.delete();
 	}
@@ -22,10 +21,10 @@
 		if (lock.mkdir())
 			return;
 
-		long deadline = System.currentTimeMillis()+ timeout;
-		while ( System.currentTimeMillis() < deadline) {
+		long deadline = System.currentTimeMillis() + timeout;
+		while (System.currentTimeMillis() < deadline) {
 			if (lock.mkdir())
-				return;	
+				return;
 			Thread.sleep(50);
 		}
 	}
diff --git a/bundleplugin/src/main/java/aQute/libg/filerepo/FileRepo.java b/bundleplugin/src/main/java/aQute/libg/filerepo/FileRepo.java
index a0149bc..e278a74 100644
--- a/bundleplugin/src/main/java/aQute/libg/filerepo/FileRepo.java
+++ b/bundleplugin/src/main/java/aQute/libg/filerepo/FileRepo.java
@@ -39,9 +39,9 @@
 				Matcher m = REPO_FILE.matcher(name);
 				if (!m.matches())
 					return false;
-				if ( versionRange == null)
+				if (versionRange == null)
 					return true;
-				
+
 				Version v = new Version(m.group(2));
 				return versionRange.includes(v);
 			}
@@ -97,10 +97,11 @@
 	}
 
 	public File put(String bsn, Version version) {
-		File dir = new File(root,bsn);
+		File dir = new File(root, bsn);
 		dir.mkdirs();
-		File file = new File(dir, bsn + "-" + version.getMajor() + "." + version.getMinor() + "." + version.getMicro() + ".jar");
+		File file = new File(dir, bsn + "-" + version.getMajor() + "." + version.getMinor() + "." + version.getMicro()
+				+ ".jar");
 		return file;
 	}
-	
+
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/forker/Forker.java b/bundleplugin/src/main/java/aQute/libg/forker/Forker.java
index 2559fad..3929ca4 100644
--- a/bundleplugin/src/main/java/aQute/libg/forker/Forker.java
+++ b/bundleplugin/src/main/java/aQute/libg/forker/Forker.java
@@ -12,12 +12,11 @@
  * have ran their associated runnable.
  * 
  * @author aqute
- * 
  * @param <T>
  */
 public class Forker<T> {
 	final Executor		executor;
-	final Map<T, Job>	waiting		= new HashMap<T, Job>();
+	final Map<T,Job>	waiting		= new HashMap<T,Job>();
 	final Set<Job>		executing	= new HashSet<Job>();
 	final AtomicBoolean	canceled	= new AtomicBoolean();
 	private int			count;
@@ -48,10 +47,12 @@
 					t = Thread.currentThread();
 				}
 				runnable.run();
-			} catch (Exception e) {
+			}
+			catch (Exception e) {
 				exception = e;
 				e.printStackTrace();
-			} finally {
+			}
+			finally {
 				synchronized (this) {
 					t = null;
 				}
@@ -84,7 +85,6 @@
 
 	/**
 	 * Constructor
-	 * 
 	 */
 	public Forker() {
 		this.executor = Executors.newFixedThreadPool(4);
@@ -101,8 +101,7 @@
 	 * @param runnable
 	 *            the runnable to run
 	 */
-	public synchronized void doWhen(Collection<? extends T> dependencies, T target,
-			Runnable runnable) {
+	public synchronized void doWhen(Collection< ? extends T> dependencies, T target, Runnable runnable) {
 		if (waiting.containsKey(target))
 			throw new IllegalArgumentException("You can only add a target once to the forker");
 
@@ -130,8 +129,7 @@
 		dependencies.removeAll(waiting.keySet());
 		if (dependencies.size() > 0)
 			throw new IllegalArgumentException(
-					"There are dependencies in the jobs that are not present in the targets: "
-							+ dependencies);
+					"There are dependencies in the jobs that are not present in the targets: " + dependencies);
 
 	}
 
@@ -181,8 +179,9 @@
 
 			for (Job job : waiting.values()) {
 				// boolean x =
-					job.dependencies.remove(done.target);
-				//System.err.println( "Removing " + done.target + " from " + job.target + " ?" + x  + " " + job.dependencies.size());
+				job.dependencies.remove(done.target);
+				// System.err.println( "Removing " + done.target + " from " +
+				// job.target + " ?" + x + " " + job.dependencies.size());
 			}
 		}
 		schedule();
diff --git a/bundleplugin/src/main/java/aQute/libg/generics/Create.java b/bundleplugin/src/main/java/aQute/libg/generics/Create.java
index ee708fd..3e071b3 100644
--- a/bundleplugin/src/main/java/aQute/libg/generics/Create.java
+++ b/bundleplugin/src/main/java/aQute/libg/generics/Create.java
@@ -3,52 +3,51 @@
 import java.util.*;
 
 public class Create {
-    
-    public static <K,V>  Map<K, V> map() {
-        return new LinkedHashMap<K,V>();
-    }
 
-    public static <K,V>  Map<K, V> map(Class<K> key, Class<V> value) {
-        return Collections.checkedMap(new LinkedHashMap<K,V>(), key,value);
-    }
+	public static <K, V> Map<K,V> map() {
+		return new LinkedHashMap<K,V>();
+	}
 
-    public static <T>  List<T> list() {
-        return new ArrayList<T>();
-    }
+	public static <K, V> Map<K,V> map(Class<K> key, Class<V> value) {
+		return Collections.checkedMap(new LinkedHashMap<K,V>(), key, value);
+	}
 
-    public static <T>  List<T> list(Class<T> c) {
-        return Collections.checkedList(new ArrayList<T>(),c) ;
-    }
+	public static <T> List<T> list() {
+		return new ArrayList<T>();
+	}
 
-    public static <T>  Set<T> set() {
-        return new HashSet<T>();
-    }
+	public static <T> List<T> list(Class<T> c) {
+		return Collections.checkedList(new ArrayList<T>(), c);
+	}
 
-    public static <T>  Set<T> set(Class<T> c) {
-        return Collections.checkedSet(new HashSet<T>(),c);
-    }
+	public static <T> Set<T> set() {
+		return new HashSet<T>();
+	}
 
-    public static <T>  List<T> list(T[] source) {
-        return new ArrayList<T>(Arrays.asList(source));
-    }
+	public static <T> Set<T> set(Class<T> c) {
+		return Collections.checkedSet(new HashSet<T>(), c);
+	}
 
-    public static <T>  Set<T> set(T[]source) {
-        return new HashSet<T>(Arrays.asList(source));
-    }
+	public static <T> List<T> list(T[] source) {
+		return new ArrayList<T>(Arrays.asList(source));
+	}
 
-    public static <K,V>  Map<K, V> copy(Map<K,V> source) {
-        return new LinkedHashMap<K,V>(source);
-    }
+	public static <T> Set<T> set(T[] source) {
+		return new HashSet<T>(Arrays.asList(source));
+	}
 
-    public static <T>  List<T> copy(List<T> source) {
-        return new ArrayList<T>(source);
-    }
+	public static <K, V> Map<K,V> copy(Map<K,V> source) {
+		return new LinkedHashMap<K,V>(source);
+	}
 
-    public static <T>  Set<T> copy(Collection<T> source) {
-        if ( source == null )
-            return set();
-        return new HashSet<T>(source);
-    }
+	public static <T> List<T> copy(List<T> source) {
+		return new ArrayList<T>(source);
+	}
 
-    
+	public static <T> Set<T> copy(Collection<T> source) {
+		if (source == null)
+			return set();
+		return new HashSet<T>(source);
+	}
+
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/glob/Glob.java b/bundleplugin/src/main/java/aQute/libg/glob/Glob.java
index c4d06a7..b48c147 100644
--- a/bundleplugin/src/main/java/aQute/libg/glob/Glob.java
+++ b/bundleplugin/src/main/java/aQute/libg/glob/Glob.java
@@ -1,22 +1,21 @@
 package aQute.libg.glob;
 
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.regex.*;
 
 public class Glob {
 
-	private final String glob;
-	private final Pattern pattern;
-	
+	private final String	glob;
+	private final Pattern	pattern;
+
 	public Glob(String globString) {
 		this.glob = globString;
 		this.pattern = Pattern.compile(convertGlobToRegEx(globString));
 	}
-	
+
 	public Matcher matcher(CharSequence input) {
 		return pattern.matcher(input);
 	}
-	
+
 	@Override
 	public String toString() {
 		return glob;
@@ -39,70 +38,70 @@
 		int inCurlies = 0;
 		for (char currentChar : line.toCharArray()) {
 			switch (currentChar) {
-			case '*':
-				if (escaping)
-					sb.append("\\*");
-				else
-					sb.append(".*");
-				escaping = false;
-				break;
-			case '?':
-				if (escaping)
-					sb.append("\\?");
-				else
-					sb.append('.');
-				escaping = false;
-				break;
-			case '.':
-			case '(':
-			case ')':
-			case '+':
-			case '|':
-			case '^':
-			case '$':
-			case '@':
-			case '%':
-				sb.append('\\');
-				sb.append(currentChar);
-				escaping = false;
-				break;
-			case '\\':
-				if (escaping) {
-					sb.append("\\\\");
+				case '*' :
+					if (escaping)
+						sb.append("\\*");
+					else
+						sb.append(".*");
 					escaping = false;
-				} else
-					escaping = true;
-				break;
-			case '{':
-				if (escaping) {
-					sb.append("\\{");
-				} else {
-					sb.append('(');
-					inCurlies++;
-				}
-				escaping = false;
-				break;
-			case '}':
-				if (inCurlies > 0 && !escaping) {
-					sb.append(')');
-					inCurlies--;
-				} else if (escaping)
-					sb.append("\\}");
-				else
-					sb.append("}");
-				escaping = false;
-				break;
-			case ',':
-				if (inCurlies > 0 && !escaping) {
-					sb.append('|');
-				} else if (escaping)
-					sb.append("\\,");
-				else
-					sb.append(",");
-				break;
-			default:
-				escaping = false;
-				sb.append(currentChar);
+					break;
+				case '?' :
+					if (escaping)
+						sb.append("\\?");
+					else
+						sb.append('.');
+					escaping = false;
+					break;
+				case '.' :
+				case '(' :
+				case ')' :
+				case '+' :
+				case '|' :
+				case '^' :
+				case '$' :
+				case '@' :
+				case '%' :
+					sb.append('\\');
+					sb.append(currentChar);
+					escaping = false;
+					break;
+				case '\\' :
+					if (escaping) {
+						sb.append("\\\\");
+						escaping = false;
+					} else
+						escaping = true;
+					break;
+				case '{' :
+					if (escaping) {
+						sb.append("\\{");
+					} else {
+						sb.append('(');
+						inCurlies++;
+					}
+					escaping = false;
+					break;
+				case '}' :
+					if (inCurlies > 0 && !escaping) {
+						sb.append(')');
+						inCurlies--;
+					} else if (escaping)
+						sb.append("\\}");
+					else
+						sb.append("}");
+					escaping = false;
+					break;
+				case ',' :
+					if (inCurlies > 0 && !escaping) {
+						sb.append('|');
+					} else if (escaping)
+						sb.append("\\,");
+					else
+						sb.append(",");
+					break;
+				default :
+					escaping = false;
+					sb.append(currentChar);
 			}
 		}
 		return sb.toString();
diff --git a/bundleplugin/src/main/java/aQute/libg/gzip/GZipUtils.java b/bundleplugin/src/main/java/aQute/libg/gzip/GZipUtils.java
index 6606d0e..81c9785 100644
--- a/bundleplugin/src/main/java/aQute/libg/gzip/GZipUtils.java
+++ b/bundleplugin/src/main/java/aQute/libg/gzip/GZipUtils.java
@@ -1,13 +1,10 @@
 package aQute.libg.gzip;
 
-import java.io.BufferedInputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.GZIPInputStream;
+import java.io.*;
+import java.util.zip.*;
 
 public class GZipUtils {
-	
+
 	/**
 	 * Determines whether the specified stream contains gzipped data, by
 	 * checking for the GZIP magic number, and returns a stream capable of
@@ -21,11 +18,11 @@
 			buffered = stream;
 		else
 			buffered = new BufferedInputStream(stream);
-		
+
 		buffered.mark(2);
 		int magic = readUShort(buffered);
 		buffered.reset();
-		
+
 		InputStream result;
 		if (magic == GZIPInputStream.GZIP_MAGIC)
 			result = new GZIPInputStream(buffered);
@@ -34,27 +31,27 @@
 		return result;
 	}
 
-    /*
-     * Reads unsigned short in Intel byte order.
-     */
+	/*
+	 * Reads unsigned short in Intel byte order.
+	 */
 	private static int readUShort(InputStream in) throws IOException {
 		int b = readUByte(in);
 		return (readUByte(in) << 8) | b;
 	}
-    
-    /*
-     * Reads unsigned byte.
-     */
-    private static int readUByte(InputStream in) throws IOException {
-	int b = in.read();
-	if (b == -1) {
-	    throw new EOFException();
+
+	/*
+	 * Reads unsigned byte.
+	 */
+	private static int readUByte(InputStream in) throws IOException {
+		int b = in.read();
+		if (b == -1) {
+			throw new EOFException();
+		}
+		if (b < -1 || b > 255) {
+			// Report on this.in, not argument in; see read{Header, Trailer}.
+			throw new IOException(in.getClass().getName() + ".read() returned value out of range -1..255: " + b);
+		}
+		return b;
 	}
-        if (b < -1 || b > 255) {
-            // Report on this.in, not argument in; see read{Header, Trailer}.
-            throw new IOException(in.getClass().getName() + ".read() returned value out of range -1..255: " + b);
-        }
-	return b;
-    }
 
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/header/Attrs.java b/bundleplugin/src/main/java/aQute/libg/header/Attrs.java
index d11b6d1..8ff65dd 100644
--- a/bundleplugin/src/main/java/aQute/libg/header/Attrs.java
+++ b/bundleplugin/src/main/java/aQute/libg/header/Attrs.java
@@ -6,9 +6,10 @@
 import aQute.lib.collections.*;
 import aQute.libg.version.*;
 
-public class Attrs implements Map<String, String> {
+public class Attrs implements Map<String,String> {
 	public enum Type {
-		STRING(null), LONG(null), VERSION(null), DOUBLE(null), STRINGS(STRING), LONGS(LONG), VERSIONS(VERSION), DOUBLES(DOUBLE);
+		STRING(null), LONG(null), VERSION(null), DOUBLE(null), STRINGS(STRING), LONGS(LONG), VERSIONS(VERSION), DOUBLES(
+				DOUBLE);
 
 		Type	sub;
 
@@ -33,14 +34,15 @@
 	 * ’List<’ scalar ’>’
 	 * </pre>
 	 */
-	static String					EXTENDED	= "[\\-0-9a-zA-Z\\._]+";
-	static String					SCALAR		= "String|Version|Long|Double";
-	static String					LIST		= "List\\s*<\\s*(" + SCALAR + ")\\s*>";
-	public static final Pattern		TYPED		= Pattern.compile("\\s*(" + EXTENDED + ")\\s*:\\s*("+ SCALAR + "|" + LIST + ")\\s*");
+	static String							EXTENDED	= "[\\-0-9a-zA-Z\\._]+";
+	static String							SCALAR		= "String|Version|Long|Double";
+	static String							LIST		= "List\\s*<\\s*(" + SCALAR + ")\\s*>";
+	public static final Pattern				TYPED		= Pattern.compile("\\s*(" + EXTENDED + ")\\s*:\\s*(" + SCALAR
+																+ "|" + LIST + ")\\s*");
 
-	private LinkedHashMap<String, String>	map;
-	private Map<String, Type>		types;
-	static Map<String, String>		EMPTY		= Collections.emptyMap();
+	private LinkedHashMap<String,String>	map;
+	private Map<String,Type>				types;
+	static Map<String,String>				EMPTY		= Collections.emptyMap();
 
 	public Attrs(Attrs... attrs) {
 		for (Attrs a : attrs) {
@@ -62,7 +64,8 @@
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public boolean containsKey(Object name) {
+	@Deprecated
+	public boolean containsKey(Object name) {
 		assert name instanceof String;
 		if (map == null)
 			return false;
@@ -78,7 +81,8 @@
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public boolean containsValue(Object value) {
+	@Deprecated
+	public boolean containsValue(Object value) {
 		assert value instanceof String;
 		if (map == null)
 			return false;
@@ -86,7 +90,7 @@
 		return map.containsValue((String) value);
 	}
 
-	public Set<java.util.Map.Entry<String, String>> entrySet() {
+	public Set<java.util.Map.Entry<String,String>> entrySet() {
 		if (map == null)
 			return EMPTY.entrySet();
 
@@ -94,7 +98,8 @@
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public String get(Object key) {
+	@Deprecated
+	public String get(Object key) {
 		assert key instanceof String;
 		if (map == null)
 			return null;
@@ -129,7 +134,7 @@
 
 	public String put(String key, String value) {
 		if (map == null)
-			map = new LinkedHashMap<String, String>();
+			map = new LinkedHashMap<String,String>();
 
 		Matcher m = TYPED.matcher(key);
 		if (m.matches()) {
@@ -137,28 +142,28 @@
 			String type = m.group(2);
 			Type t = Type.STRING;
 
-			if ( type.startsWith("List")) {
+			if (type.startsWith("List")) {
 				type = m.group(3);
-				if ( "String".equals(type))
+				if ("String".equals(type))
 					t = Type.STRINGS;
-				else if ( "Long".equals(type))
+				else if ("Long".equals(type))
 					t = Type.LONGS;
-				else if ( "Double".equals(type))
+				else if ("Double".equals(type))
 					t = Type.DOUBLES;
-				else if ( "Version".equals(type))
-					t = Type.VERSIONS;				
+				else if ("Version".equals(type))
+					t = Type.VERSIONS;
 			} else {
-				if ( "String".equals(type))
+				if ("String".equals(type))
 					t = Type.STRING;
-				else if ( "Long".equals(type))
+				else if ("Long".equals(type))
 					t = Type.LONG;
-				else if ( "Double".equals(type))
+				else if ("Double".equals(type))
 					t = Type.DOUBLE;
-				else if ( "Version".equals(type))
+				else if ("Version".equals(type))
 					t = Type.VERSION;
 			}
 			if (types == null)
-				types = new LinkedHashMap<String, Type>();
+				types = new LinkedHashMap<String,Type>();
 			types.put(key, t);
 
 			// TODO verify value?
@@ -176,13 +181,14 @@
 		return t;
 	}
 
-	public void putAll(Map<? extends String, ? extends String> map) {
-		for (Map.Entry<? extends String, ? extends String> e : map.entrySet())
+	public void putAll(Map< ? extends String, ? extends String> map) {
+		for (Map.Entry< ? extends String, ? extends String> e : map.entrySet())
 			put(e.getKey(), e.getValue());
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public String remove(Object var0) {
+	@Deprecated
+	public String remove(Object var0) {
 		assert var0 instanceof String;
 		if (map == null)
 			return null;
@@ -221,7 +227,7 @@
 
 	public void append(StringBuilder sb) {
 		String del = "";
-		for (Map.Entry<String, String> e : entrySet()) {
+		for (Map.Entry<String,String> e : entrySet()) {
 			sb.append(del);
 			sb.append(e.getKey());
 			sb.append("=");
@@ -230,11 +236,13 @@
 		}
 	}
 
-	@Deprecated public boolean equals(Object other) {
+	@Deprecated
+	public boolean equals(Object other) {
 		return super.equals(other);
 	}
 
-	@Deprecated public int hashCode() {
+	@Deprecated
+	public int hashCode() {
 		return super.hashCode();
 	}
 
@@ -275,12 +283,12 @@
 	private Object convert(Type t, String s) {
 		if (t.sub == null) {
 			switch (t) {
-			case STRING:
-				return s;
-			case LONG:
-				return Long.parseLong(s.trim());
-			case VERSION:
-				return Version.parseVersion(s);
+				case STRING :
+					return s;
+				case LONG :
+					return Long.parseLong(s.trim());
+				case VERSION :
+					return Version.parseVersion(s);
 			}
 			return null;
 		}
diff --git a/bundleplugin/src/main/java/aQute/libg/header/OSGiHeader.java b/bundleplugin/src/main/java/aQute/libg/header/OSGiHeader.java
index 7b26f6f..6be995a 100755
--- a/bundleplugin/src/main/java/aQute/libg/header/OSGiHeader.java
+++ b/bundleplugin/src/main/java/aQute/libg/header/OSGiHeader.java
@@ -15,9 +15,8 @@
 	/**
 	 * Standard OSGi header parser. This parser can handle the format clauses
 	 * ::= clause ( ',' clause ) + clause ::= name ( ';' name ) (';' key '='
-	 * value )
-	 * 
-	 * This is mapped to a Map { name => Map { attr|directive => value } }
+	 * value ) This is mapped to a Map { name => Map { attr|directive => value }
+	 * }
 	 * 
 	 * @param value
 	 *            A string
@@ -56,10 +55,8 @@
 					if ((del = qt.getSeparator()) != '=') {
 						if (hadAttribute)
 							if (logger != null) {
-								logger.error("Header contains name field after attribute or directive: "
-										+ adname
-										+ " from "
-										+ value
+								logger.error("Header contains name field after attribute or directive: " + adname
+										+ " from " + value
 										+ ". Name fields must be consecutive, separated by a ';' like a;b;c;x=3;y=4");
 							}
 						if (adname != null && adname.length() > 0)
@@ -68,8 +65,7 @@
 						String advalue = qt.nextToken();
 						if (clause.containsKey(adname)) {
 							if (logger != null && logger.isPedantic())
-								logger.warning("Duplicate attribute/directive name " + adname
-										+ " in " + value
+								logger.warning("Duplicate attribute/directive name " + adname + " in " + value
 										+ ". This attribute/directive will be ignored");
 						}
 						if (advalue == null) {
diff --git a/bundleplugin/src/main/java/aQute/libg/header/Parameters.java b/bundleplugin/src/main/java/aQute/libg/header/Parameters.java
index 96f0d08..f2354c4 100644
--- a/bundleplugin/src/main/java/aQute/libg/header/Parameters.java
+++ b/bundleplugin/src/main/java/aQute/libg/header/Parameters.java
@@ -5,13 +5,12 @@
 import aQute.lib.collections.*;
 import aQute.libg.reporter.*;
 
-public class Parameters implements Map<String, Attrs> {
-	private LinkedHashMap<String, Attrs>	map;
-	static Map<String, Attrs>				EMPTY	= Collections.emptyMap();
-	String									error;
+public class Parameters implements Map<String,Attrs> {
+	private LinkedHashMap<String,Attrs>	map;
+	static Map<String,Attrs>			EMPTY	= Collections.emptyMap();
+	String								error;
 
-	public Parameters() {
-	}
+	public Parameters() {}
 
 	public Parameters(String header) {
 		OSGiHeader.parseHeader(header, null, this);
@@ -33,7 +32,8 @@
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public boolean containsKey(Object name) {
+	@Deprecated
+	public boolean containsKey(Object name) {
 		assert name instanceof String;
 		if (map == null)
 			return false;
@@ -49,7 +49,8 @@
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public boolean containsValue(Object value) {
+	@Deprecated
+	public boolean containsValue(Object value) {
 		assert value instanceof Attrs;
 		if (map == null)
 			return false;
@@ -57,7 +58,7 @@
 		return map.containsValue((Attrs) value);
 	}
 
-	public Set<java.util.Map.Entry<String, Attrs>> entrySet() {
+	public Set<java.util.Map.Entry<String,Attrs>> entrySet() {
 		if (map == null)
 			return EMPTY.entrySet();
 
@@ -65,7 +66,8 @@
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public Attrs get(Object key) {
+	@Deprecated
+	public Attrs get(Object key) {
 		assert key instanceof String;
 		if (map == null)
 			return null;
@@ -96,28 +98,30 @@
 		assert value != null;
 
 		if (map == null)
-			map = new LinkedHashMap<String, Attrs>();
+			map = new LinkedHashMap<String,Attrs>();
 
 		return map.put(key, value);
 	}
 
-	public void putAll(Map<? extends String, ? extends Attrs> map) {
+	public void putAll(Map< ? extends String, ? extends Attrs> map) {
 		if (this.map == null) {
 			if (map.isEmpty())
 				return;
-			this.map = new LinkedHashMap<String, Attrs>();
+			this.map = new LinkedHashMap<String,Attrs>();
 		}
 		this.map.putAll(map);
 	}
+
 	public void putAllIfAbsent(Map<String, ? extends Attrs> map) {
-		for(Map.Entry<String, ? extends Attrs> entry : map.entrySet() ) {
-			if ( !containsKey(entry.getKey()))
+		for (Map.Entry<String, ? extends Attrs> entry : map.entrySet()) {
+			if (!containsKey(entry.getKey()))
 				put(entry.getKey(), entry.getValue());
 		}
 	}
 
 	@SuppressWarnings("cast")
-	@Deprecated public Attrs remove(Object var0) {
+	@Deprecated
+	public Attrs remove(Object var0) {
 		assert var0 instanceof String;
 		if (map == null)
 			return null;
@@ -152,7 +156,7 @@
 
 	public void append(StringBuilder sb) {
 		String del = "";
-		for (Map.Entry<String, Attrs> s : entrySet()) {
+		for (Map.Entry<String,Attrs> s : entrySet()) {
 			sb.append(del);
 			sb.append(s.getKey());
 			if (!s.getValue().isEmpty()) {
@@ -168,12 +172,11 @@
 	public boolean equals(Object other) {
 		return super.equals(other);
 	}
-	
+
 	@Deprecated
 	public int hashCode() {
 		return super.hashCode();
 	}
-	
 
 	public boolean isEqual(Parameters other) {
 		if (this == other)
@@ -197,7 +200,7 @@
 		return true;
 	}
 
-	public Map<String,? extends Map<String,String>> asMapMap() {
+	public Map<String, ? extends Map<String,String>> asMapMap() {
 		return this;
 	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/log/Logger.java b/bundleplugin/src/main/java/aQute/libg/log/Logger.java
index bb87707..05d869f 100755
--- a/bundleplugin/src/main/java/aQute/libg/log/Logger.java
+++ b/bundleplugin/src/main/java/aQute/libg/log/Logger.java
@@ -2,15 +2,18 @@
 
 import java.util.*;
 
-
 public interface Logger {
-	void error(String s, Object ... args);
-	void warning(String s, Object ... args);
-	void progress(String s, Object ... args);
-	
+	void error(String s, Object... args);
+
+	void warning(String s, Object... args);
+
+	void progress(String s, Object... args);
+
 	List<String> getWarnings();
+
 	List<String> getErrors();
+
 	List<String> getProgress();
-	
+
 	boolean isPedantic();
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/map/MAP.java b/bundleplugin/src/main/java/aQute/libg/map/MAP.java
index 41c588b..e4776f7 100644
--- a/bundleplugin/src/main/java/aQute/libg/map/MAP.java
+++ b/bundleplugin/src/main/java/aQute/libg/map/MAP.java
@@ -3,42 +3,40 @@
 import java.util.*;
 
 /**
- * Easy way to build a map:
- * 
- * 	Map<String,Integer> s = MAP.$("a",2).$("b",3);
- *
+ * Easy way to build a map: Map<String,Integer> s = MAP.$("a",2).$("b",3);
  */
 public class MAP {
 
-	static public class MAPX<K, V> extends LinkedHashMap<K, V> {
+	static public class MAPX<K, V> extends LinkedHashMap<K,V> {
 		private static final long	serialVersionUID	= 1L;
-		public MAPX<K, V> $(K key, V value) {
+
+		public MAPX<K,V> $(K key, V value) {
 			put(key, value);
 			return this;
 		}
 
-		public MAPX<K, V> $(Map<K,V> all) {
+		public MAPX<K,V> $(Map<K,V> all) {
 			putAll(all);
 			return this;
 		}
+
 		public Hashtable<K,V> asHashtable() {
 			return new Hashtable<K,V>(this);
 		}
 	}
 
-	public static <Kx, Vx> MAPX<Kx, Vx> $(Kx key, Vx value) {
-		MAPX<Kx, Vx> map = new MAPX<Kx, Vx>();
+	public static <Kx, Vx> MAPX<Kx,Vx> $(Kx key, Vx value) {
+		MAPX<Kx,Vx> map = new MAPX<Kx,Vx>();
 		map.put(key, value);
 		return map;
 	}
-	
-	
-	public <K,V> Map<K,V> dictionary(Dictionary<K,V> dict ) {
-		Map<K,V> map = new LinkedHashMap<K, V>();
-		for ( Enumeration<K> e = dict.keys(); e.hasMoreElements(); ) {
+
+	public <K, V> Map<K,V> dictionary(Dictionary<K,V> dict) {
+		Map<K,V> map = new LinkedHashMap<K,V>();
+		for (Enumeration<K> e = dict.keys(); e.hasMoreElements();) {
 			K k = e.nextElement();
 			V v = dict.get(k);
-			map.put(k,v);
+			map.put(k, v);
 		}
 		return map;
 	}
diff --git a/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java b/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java
index 58ea539..c8dcb41 100755
--- a/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java
+++ b/bundleplugin/src/main/java/aQute/libg/qtokens/QuotedTokenizer.java
@@ -13,40 +13,41 @@
 	String	peek;
 	char	separator;
 
-	public QuotedTokenizer(String string, String separators, boolean returnTokens ) {
-		if ( string == null )
+	public QuotedTokenizer(String string, String separators, boolean returnTokens) {
+		if (string == null)
 			throw new IllegalArgumentException("string argument must be not null");
 		this.string = string;
 		this.separators = separators;
 		this.returnTokens = returnTokens;
 	}
+
 	public QuotedTokenizer(String string, String separators) {
-		this(string,separators,false);
+		this(string, separators, false);
 	}
 
 	public String nextToken(String separators) {
 		separator = 0;
-		if ( peek != null ) {
+		if (peek != null) {
 			String tmp = peek;
 			peek = null;
 			return tmp;
 		}
-		
-		if ( index == string.length())
+
+		if (index == string.length())
 			return null;
-		
+
 		StringBuilder sb = new StringBuilder();
 
 		while (index < string.length()) {
 			char c = string.charAt(index++);
 
-			if ( Character.isWhitespace(c)) {
-				if ( index == string.length())
+			if (Character.isWhitespace(c)) {
+				if (index == string.length())
 					break;
 				sb.append(c);
 				continue;
 			}
-			
+
 			if (separators.indexOf(c) >= 0) {
 				if (returnTokens)
 					peek = Character.toString(c);
@@ -66,7 +67,7 @@
 			}
 		}
 		String result = sb.toString().trim();
-		if ( result.length()==0 && index==string.length())
+		if (result.length() == 0 && index == string.length())
 			return null;
 		return result;
 	}
@@ -81,8 +82,7 @@
 			c = string.charAt(index++);
 			if (c == quote)
 				break;
-			if (c == '\\' && index < string.length()
-					&& string.charAt(index + 1) == quote)
+			if (c == '\\' && index < string.length() && string.charAt(index + 1) == quote)
 				c = string.charAt(index++);
 			sb.append(c);
 		}
@@ -92,22 +92,24 @@
 		return getTokens(0);
 	}
 
-	private String [] getTokens(int cnt){
+	private String[] getTokens(int cnt) {
 		String token = nextToken();
-		if ( token == null ) 
+		if (token == null)
 			return new String[cnt];
-		
-		String result[] = getTokens(cnt+1);
-		result[cnt]=token;
+
+		String result[] = getTokens(cnt + 1);
+		result[cnt] = token;
 		return result;
 	}
 
-	public char getSeparator() { return separator; }
-	
+	public char getSeparator() {
+		return separator;
+	}
+
 	public List<String> getTokenSet() {
 		List<String> list = Create.list();
 		String token = nextToken();
-		while ( token != null ) {
+		while (token != null) {
 			list.add(token);
 			token = nextToken();
 		}
diff --git a/bundleplugin/src/main/java/aQute/libg/reporter/Message.java b/bundleplugin/src/main/java/aQute/libg/reporter/Message.java
new file mode 100644
index 0000000..28386c0
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/libg/reporter/Message.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package aQute.libg.reporter;
+
+public @interface Message {
+	String value();
+}
diff --git a/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java b/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java
new file mode 100644
index 0000000..504c10a
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/libg/reporter/Messages.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package aQute.libg.reporter;
+
+import java.io.*;
+
+public interface Messages {
+	static public class ERROR {}
+
+	static public class WARNING {}
+
+	ERROR NoSuchFile_(File f);
+
+	ERROR Unexpected_Error_(String context, Exception e);
+
+}
diff --git a/bundleplugin/src/main/java/aQute/libg/reporter/Reporter.java b/bundleplugin/src/main/java/aQute/libg/reporter/Reporter.java
index c6179af..1ad0c31 100755
--- a/bundleplugin/src/main/java/aQute/libg/reporter/Reporter.java
+++ b/bundleplugin/src/main/java/aQute/libg/reporter/Reporter.java
@@ -2,14 +2,20 @@
 
 import java.util.*;
 
-
 public interface Reporter {
-	void error(String s, Object ... args);
-	void warning(String s, Object ... args);
-	void progress(String s, Object ... args);
-	void trace(String s, Object ... args);
+	void error(String s, Object... args);
+
+	void warning(String s, Object... args);
+
+	void progress(String s, Object... args);
+
+	void trace(String s, Object... args);
+
 	List<String> getWarnings();
+
 	List<String> getErrors();
-	
+
 	boolean isPedantic();
+	
+	boolean isExceptions();
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java b/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java
index 249b776..676fb1b 100644
--- a/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java
+++ b/bundleplugin/src/main/java/aQute/libg/reporter/ReporterAdapter.java
@@ -8,7 +8,6 @@
 
 /**
  * Mainly used for testing where reporters are needed.
- * 
  */
 public class ReporterAdapter implements Reporter {
 	final List<String>	errors		= new ArrayList<String>();
@@ -74,7 +73,7 @@
 		errors.add(e);
 		trace("ERROR: %s", e);
 		if (isExceptions() || isTrace())
-			if ( t instanceof InvocationTargetException )
+			if (t instanceof InvocationTargetException)
 				t.getCause().printStackTrace(System.err);
 			else
 				t.printStackTrace(System.err);
@@ -89,14 +88,14 @@
 	public void progress(String s, Object... args) {
 		if (out != null) {
 			out.format(s, args);
-			if ( !s.endsWith("\n"))
+			if (!s.endsWith("\n"))
 				out.format("\n");
 		}
 	}
 
 	public void trace(String s, Object... args) {
 		if (trace && out != null) {
-			out.format("# "+s+"\n", args);
+			out.format("# " + s + "\n", args);
 			out.flush();
 		}
 	}
@@ -172,8 +171,8 @@
 	void report(String title, Collection<String> list, Formatter f) {
 		if (list.isEmpty())
 			return;
-		f.format(title + (list.size() > 1 ? "s" : "")+"\n");
-		int n=0;
+		f.format(title + (list.size() > 1 ? "s" : "") + "\n");
+		int n = 0;
 		for (String s : list) {
 			f.format("%3s. %s\n", n++, s);
 		}
diff --git a/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java b/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java
new file mode 100644
index 0000000..8d782cf
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/libg/reporter/ReporterMessages.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) OSGi Alliance (2012). All Rights Reserved.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package aQute.libg.reporter;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import aQute.libg.reporter.Messages.ERROR;
+import aQute.libg.reporter.Messages.WARNING;
+
+public class ReporterMessages {
+
+	@SuppressWarnings("unchecked")
+	public static <T> T base(final Reporter reporter, Class<T> messages) {
+		return (T) Proxy.newProxyInstance(messages.getClassLoader(), new Class[] {
+			messages
+		}, new InvocationHandler() {
+
+			public Object invoke(Object target, Method method, Object[] args) throws Throwable {
+				if (reporter.isExceptions()) {
+					for (Object o : args) {
+						if (o instanceof Throwable)
+							((Throwable) o).printStackTrace();
+					}
+				}
+				String format;
+				Message d = method.getAnnotation(Message.class);
+				if (d == null) {
+					String name = method.getName();
+					StringBuilder sb = new StringBuilder();
+					sb.append(name.charAt(0));
+					for (int i = 1; i < name.length(); i++) {
+						char c = name.charAt(i);
+						switch (c) {
+							case '_' :
+								sb.append(" %s, ");
+								break;
+
+							default :
+								if (Character.isUpperCase(c)) {
+									sb.append(" ");
+									c = Character.toLowerCase(c);
+								}
+								sb.append(c);
+						}
+					}
+					format = sb.toString();
+				} else
+					format = d.value();
+
+				try {
+					if (method.getReturnType() == ERROR.class) {
+						reporter.error(format, args);
+					} else if (method.getReturnType() == WARNING.class) {
+						reporter.warning(format, args);
+					} else
+						reporter.trace(format, args);
+				}
+				catch (IllegalFormatException e) {
+					reporter.error("Formatter failed: %s %s %s", method.getName(), format, Arrays.toString(args));
+				}
+				return null;
+			}
+		});
+	}
+}
diff --git a/bundleplugin/src/main/java/aQute/libg/sax/ContentFilter.java b/bundleplugin/src/main/java/aQute/libg/sax/ContentFilter.java
index 62ca259..e08f4de 100644
--- a/bundleplugin/src/main/java/aQute/libg/sax/ContentFilter.java
+++ b/bundleplugin/src/main/java/aQute/libg/sax/ContentFilter.java
@@ -1,8 +1,9 @@
 package aQute.libg.sax;
 
-import org.xml.sax.ContentHandler;
+import org.xml.sax.*;
 
 public interface ContentFilter extends ContentHandler {
 	void setParent(ContentHandler parent);
+
 	ContentHandler getParent();
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/sax/ContentFilterImpl.java b/bundleplugin/src/main/java/aQute/libg/sax/ContentFilterImpl.java
index 7f71568..3bfb6b5 100644
--- a/bundleplugin/src/main/java/aQute/libg/sax/ContentFilterImpl.java
+++ b/bundleplugin/src/main/java/aQute/libg/sax/ContentFilterImpl.java
@@ -1,17 +1,14 @@
 package aQute.libg.sax;
 
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
+import org.xml.sax.*;
 
 public class ContentFilterImpl implements ContentFilter {
 
-	private ContentHandler parent;
+	private ContentHandler	parent;
 
 	public void setParent(ContentHandler parent) {
 		this.parent = parent;
-		
+
 	}
 
 	public ContentHandler getParent() {
@@ -30,8 +27,7 @@
 		parent.endDocument();
 	}
 
-	public void startPrefixMapping(String prefix, String uri)
-			throws SAXException {
+	public void startPrefixMapping(String prefix, String uri) throws SAXException {
 		parent.startPrefixMapping(prefix, uri);
 	}
 
@@ -39,28 +35,23 @@
 		parent.endPrefixMapping(prefix);
 	}
 
-	public void startElement(String uri, String localName, String qName,
-			Attributes atts) throws SAXException {
+	public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
 		parent.startElement(uri, localName, qName, atts);
 	}
 
-	public void endElement(String uri, String localName, String qName)
-			throws SAXException {
+	public void endElement(String uri, String localName, String qName) throws SAXException {
 		parent.endElement(uri, localName, qName);
 	}
 
-	public void characters(char[] ch, int start, int length)
-			throws SAXException {
+	public void characters(char[] ch, int start, int length) throws SAXException {
 		parent.characters(ch, start, length);
 	}
 
-	public void ignorableWhitespace(char[] ch, int start, int length)
-			throws SAXException {
+	public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
 		parent.ignorableWhitespace(ch, start, length);
 	}
 
-	public void processingInstruction(String target, String data)
-			throws SAXException {
+	public void processingInstruction(String target, String data) throws SAXException {
 		parent.processingInstruction(target, data);
 	}
 
diff --git a/bundleplugin/src/main/java/aQute/libg/sax/SAXElement.java b/bundleplugin/src/main/java/aQute/libg/sax/SAXElement.java
index b7ce35e..0b7e914 100644
--- a/bundleplugin/src/main/java/aQute/libg/sax/SAXElement.java
+++ b/bundleplugin/src/main/java/aQute/libg/sax/SAXElement.java
@@ -1,16 +1,15 @@
 package aQute.libg.sax;
 
-import org.xml.sax.Attributes;
+import org.xml.sax.*;
 
 public class SAXElement {
 
-	private final String uri;
-	private final String localName;
-	private final String qName;
-	private final Attributes atts;
+	private final String		uri;
+	private final String		localName;
+	private final String		qName;
+	private final Attributes	atts;
 
-	public SAXElement(String uri, String localName, String qName,
-			Attributes atts) {
+	public SAXElement(String uri, String localName, String qName, Attributes atts) {
 		this.uri = uri;
 		this.localName = localName;
 		this.qName = qName;
diff --git a/bundleplugin/src/main/java/aQute/libg/sax/SAXUtil.java b/bundleplugin/src/main/java/aQute/libg/sax/SAXUtil.java
index 87b058e..ab7b470 100644
--- a/bundleplugin/src/main/java/aQute/libg/sax/SAXUtil.java
+++ b/bundleplugin/src/main/java/aQute/libg/sax/SAXUtil.java
@@ -1,29 +1,28 @@
 package aQute.libg.sax;
 
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.parsers.*;
+import javax.xml.transform.*;
+import javax.xml.transform.sax.*;
 
-import org.xml.sax.ContentHandler;
-import org.xml.sax.XMLReader;
+import org.xml.sax.*;
 
 public class SAXUtil {
-	
+
 	public static XMLReader buildPipeline(Result output, ContentFilter... filters) throws Exception {
 		SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
 		TransformerHandler handler = factory.newTransformerHandler();
 		handler.setResult(output);
-		
+
 		ContentHandler last = handler;
-		if (filters != null) for (ContentFilter filter : filters) {
-			filter.setParent(last);
-			last = filter;
-		}
+		if (filters != null)
+			for (ContentFilter filter : filters) {
+				filter.setParent(last);
+				last = filter;
+			}
 		XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
 		reader.setContentHandler(last);
-		
+
 		return reader;
 	}
-	
+
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/sax/filters/ElementSelectionFilter.java b/bundleplugin/src/main/java/aQute/libg/sax/filters/ElementSelectionFilter.java
index 4411db9..3ba7f5a 100644
--- a/bundleplugin/src/main/java/aQute/libg/sax/filters/ElementSelectionFilter.java
+++ b/bundleplugin/src/main/java/aQute/libg/sax/filters/ElementSelectionFilter.java
@@ -1,17 +1,16 @@
 package aQute.libg.sax.filters;
 
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
+import org.xml.sax.*;
 
-import aQute.libg.sax.ContentFilterImpl;
+import aQute.libg.sax.*;
 
-public abstract class ElementSelectionFilter extends ContentFilterImpl{
-	
-	int depth = 0;
-	int hiddenDepth = -1;
-	
+public abstract class ElementSelectionFilter extends ContentFilterImpl {
+
+	int	depth		= 0;
+	int	hiddenDepth	= -1;
+
 	protected abstract boolean select(int depth, String uri, String localName, String qName, Attributes attribs);
-	
+
 	@Override
 	public final void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
 		if (hiddenDepth < 0) {
@@ -21,29 +20,31 @@
 			else
 				hiddenDepth = 0;
 		} else {
-			hiddenDepth ++;
+			hiddenDepth++;
 		}
 		depth++;
 	}
-	
+
 	@Override
 	public final void endElement(String uri, String localName, String qName) throws SAXException {
 		if (hiddenDepth < 0) {
 			super.endElement(uri, localName, qName);
 		} else {
-			hiddenDepth --;
+			hiddenDepth--;
 		}
-		depth --;
+		depth--;
 	}
-	
+
 	@Override
 	public void characters(char[] ch, int start, int length) throws SAXException {
-		if (hiddenDepth < 0) super.characters(ch, start, length);
+		if (hiddenDepth < 0)
+			super.characters(ch, start, length);
 	}
-	
+
 	@Override
 	public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
-		if (hiddenDepth < 0) super.ignorableWhitespace(ch, start, length);
+		if (hiddenDepth < 0)
+			super.ignorableWhitespace(ch, start, length);
 	}
-	
+
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/sax/filters/MergeContentFilter.java b/bundleplugin/src/main/java/aQute/libg/sax/filters/MergeContentFilter.java
index acf5d12..b0d4df8 100644
--- a/bundleplugin/src/main/java/aQute/libg/sax/filters/MergeContentFilter.java
+++ b/bundleplugin/src/main/java/aQute/libg/sax/filters/MergeContentFilter.java
@@ -1,28 +1,26 @@
 package aQute.libg.sax.filters;
 
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
 
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
+import org.xml.sax.*;
 
-import aQute.libg.sax.ContentFilterImpl;
-import aQute.libg.sax.SAXElement;
+import aQute.libg.sax.*;
 
 public class MergeContentFilter extends ContentFilterImpl {
 
-	private int elementDepth = 0;
-	
-	private final List<SAXElement> rootElements = new LinkedList<SAXElement>();
-	
+	private int						elementDepth	= 0;
+
+	private final List<SAXElement>	rootElements	= new LinkedList<SAXElement>();
+
 	@Override
 	public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
 		if (elementDepth++ == 0) {
 			if (rootElements.isEmpty())
 				super.startElement(uri, localName, qName, atts);
 			else if (!rootElements.get(0).getqName().equals(qName))
-				throw new SAXException(String.format("Documents have inconsistent root element names: first was %s, current is %s.", rootElements.get(0).getqName(), qName));
+				throw new SAXException(String.format(
+						"Documents have inconsistent root element names: first was %s, current is %s.", rootElements
+								.get(0).getqName(), qName));
 			rootElements.add(new SAXElement(uri, localName, qName, atts));
 		} else {
 			super.startElement(uri, localName, qName, atts);
@@ -35,13 +33,13 @@
 			super.endElement(uri, localName, qName);
 		}
 	}
-	
+
 	@Override
 	public void processingInstruction(String target, String data) throws SAXException {
 		if (rootElements.isEmpty())
 			super.processingInstruction(target, data);
 	}
-	
+
 	public void closeRootAndDocument() throws SAXException {
 		if (!rootElements.isEmpty()) {
 			SAXElement root = rootElements.get(0);
@@ -49,7 +47,7 @@
 		}
 		super.endDocument();
 	}
-	
+
 	public List<SAXElement> getRootElements() {
 		return Collections.unmodifiableList(rootElements);
 	}
diff --git a/bundleplugin/src/main/java/aQute/libg/sed/Replacer.java b/bundleplugin/src/main/java/aQute/libg/sed/Replacer.java
index fa181f4..3c02aaf 100644
--- a/bundleplugin/src/main/java/aQute/libg/sed/Replacer.java
+++ b/bundleplugin/src/main/java/aQute/libg/sed/Replacer.java
@@ -1,5 +1,5 @@
 package aQute.libg.sed;
 
 public interface Replacer {
-    String process(String line);
+	String process(String line);
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/sed/Sed.java b/bundleplugin/src/main/java/aQute/libg/sed/Sed.java
index 74f4756..4642c92 100644
--- a/bundleplugin/src/main/java/aQute/libg/sed/Sed.java
+++ b/bundleplugin/src/main/java/aQute/libg/sed/Sed.java
@@ -4,96 +4,98 @@
 import java.util.*;
 import java.util.regex.*;
 
+import aQute.lib.io.IO;
+
 public class Sed {
-    final File                 file;
-    final Replacer             macro;
-    File                       output;
-    boolean backup = true;
+	final File					file;
+	final Replacer				macro;
+	File						output;
+	boolean						backup			= true;
 
-    final Map<Pattern, String> replacements = new LinkedHashMap<Pattern, String>();
+	final Map<Pattern,String>	replacements	= new LinkedHashMap<Pattern,String>();
 
-    public Sed(Replacer macro, File file) {
-        assert file.isFile();
-        this.file = file;
-        this.macro = macro;
-    }
-    
-    public Sed(File file) {
-        assert file.isFile();
-        this.file = file;
-        this.macro = null;
-    }
+	public Sed(Replacer macro, File file) {
+		assert file.isFile();
+		this.file = file;
+		this.macro = macro;
+	}
 
-    public void setOutput(File f) {
-        output = f;
-    }
+	public Sed(File file) {
+		assert file.isFile();
+		this.file = file;
+		this.macro = null;
+	}
 
-    public void replace(String pattern, String replacement) {
-        replacements.put(Pattern.compile(pattern), replacement);
-    }
+	public void setOutput(File f) {
+		output = f;
+	}
 
-    public int doIt() throws IOException {
-    	int actions = 0;
-        BufferedReader brdr = new BufferedReader(new InputStreamReader( new FileInputStream(file),"UTF-8"));
-        File out;
-        if (output != null)
-            out = output;
-        else
-            out = new File(file.getAbsolutePath() + ".tmp");
-        PrintWriter pw = new PrintWriter(new OutputStreamWriter( new FileOutputStream(out),"UTF-8"));
-        try {
-            String line;
-            while ((line = brdr.readLine()) != null) {
-                for (Pattern p : replacements.keySet()) {
-                    String replace = replacements.get(p);
-                    Matcher m = p.matcher(line);
+	public void replace(String pattern, String replacement) {
+		replacements.put(Pattern.compile(pattern), replacement);
+	}
 
-                    StringBuffer sb = new StringBuffer();
-                    while (m.find()) {
-                        String tmp = setReferences(m, replace);
-                        if ( macro != null)
-                        	tmp = Matcher.quoteReplacement(macro.process(tmp));
-                        m.appendReplacement(sb, tmp);
-                        actions++;
-                    }
-                    m.appendTail(sb);
+	public int doIt() throws IOException {
+		int actions = 0;
+		BufferedReader brdr = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
+		File out;
+		if (output != null)
+			out = output;
+		else
+			out = new File(file.getAbsolutePath() + ".tmp");
+		PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(out), "UTF-8"));
+		try {
+			String line;
+			while ((line = brdr.readLine()) != null) {
+				for (Pattern p : replacements.keySet()) {
+					String replace = replacements.get(p);
+					Matcher m = p.matcher(line);
 
-                    line = sb.toString();
-                }
-                pw.println(line);
-            }
-            pw.close();
-            if (output == null) {
-            	if ( backup ) {
-                    File bak = new File(file.getAbsolutePath() + ".bak");
-            		file.renameTo(bak);
-            	}
-                out.renameTo(file);
-            }
+					StringBuffer sb = new StringBuffer();
+					while (m.find()) {
+						String tmp = setReferences(m, replace);
+						if (macro != null)
+							tmp = Matcher.quoteReplacement(macro.process(tmp));
+						m.appendReplacement(sb, tmp);
+						actions++;
+					}
+					m.appendTail(sb);
+
+					line = sb.toString();
+				}
+				pw.println(line);
+			}
         } finally {
-            brdr.close();
-            pw.close();
+        	brdr.close();
+			pw.close();
         }
-        return actions;
-    }
+        
+		if (output == null) {
+			if (backup) {
+				File bak = new File(file.getAbsolutePath() + ".bak");
+				IO.rename(file, bak);
+			}
+			IO.rename(out, file);
+		}
+        
+		return actions;
+	}
+    
+	private String setReferences(Matcher m, String replace) {
+		StringBuilder sb = new StringBuilder();
+		for (int i = 0; i < replace.length(); i++) {
+			char c = replace.charAt(i);
+			if (c == '$' && i < replace.length() - 1 && Character.isDigit(replace.charAt(i + 1))) {
+				int n = replace.charAt(i + 1) - '0';
+				if (n <= m.groupCount())
+					sb.append(m.group(n));
+				i++;
+			} else
+				sb.append(c);
+		}
+		return sb.toString();
+	}
 
-    private String setReferences(Matcher m, String replace) {
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < replace.length(); i++) {
-            char c = replace.charAt(i);
-            if (c == '$' && i < replace.length() - 1
-                    && Character.isDigit(replace.charAt(i + 1))) {
-                int n = replace.charAt(i + 1) - '0';
-                if ( n <= m.groupCount() )
-                    sb.append(m.group(n));
-                i++;
-            } else
-                sb.append(c);
-        }
-        return sb.toString();
-    }
-
-    public void setBackup(boolean b) {
-    	this.backup=b;
-    }
+	public void setBackup(boolean b) {
+		this.backup = b;
+	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/tarjan/Tarjan.java b/bundleplugin/src/main/java/aQute/libg/tarjan/Tarjan.java
index 3d05b76..cef8b23 100644
--- a/bundleplugin/src/main/java/aQute/libg/tarjan/Tarjan.java
+++ b/bundleplugin/src/main/java/aQute/libg/tarjan/Tarjan.java
@@ -15,43 +15,42 @@
 		public Node(T name) {
 			this.name = name;
 		}
-		
+
 		public String toString() {
 			return name + "{" + index + "," + low + "}";
 		}
 	}
 
-	private int				index	= 0;
-	private List<Node>		stack	= new ArrayList<Node>();
+	private int			index	= 0;
+	private List<Node>	stack	= new ArrayList<Node>();
 	private Set<Set<T>>	scc		= new HashSet<Set<T>>();
-	private Node			root	= new Node(null);
+	private Node		root	= new Node(null);
 
-	
-//	   public ArrayList<ArrayList<Node>> tarjan(Node v, AdjacencyList list){
-//	       v.index = index;
-//	       v.lowlink = index;
-//	       index++;
-//	       stack.add(0, v);
-//	       for(Edge e : list.getAdjacent(v)){
-//	           Node n = e.to;
-//	           if(n.index == -1){
-//	               tarjan(n, list);
-//	               v.lowlink = Math.min(v.lowlink, n.lowlink);
-//	           }else if(stack.contains(n)){
-//	               v.lowlink = Math.min(v.lowlink, n.index);
-//	           }
-//	       }
-//	       if(v.lowlink == v.index){
-//	           Node n;
-//	           ArrayList<Node> component = new ArrayList<Node>();
-//	           do{
-//	               n = stack.remove(0);
-//	               component.add(n);
-//	           }while(n != v);
-//	           SCC.add(component);
-//	       }
-//	       return SCC;
-//	   }
+	// public ArrayList<ArrayList<Node>> tarjan(Node v, AdjacencyList list){
+	// v.index = index;
+	// v.lowlink = index;
+	// index++;
+	// stack.add(0, v);
+	// for(Edge e : list.getAdjacent(v)){
+	// Node n = e.to;
+	// if(n.index == -1){
+	// tarjan(n, list);
+	// v.lowlink = Math.min(v.lowlink, n.lowlink);
+	// }else if(stack.contains(n)){
+	// v.lowlink = Math.min(v.lowlink, n.index);
+	// }
+	// }
+	// if(v.lowlink == v.index){
+	// Node n;
+	// ArrayList<Node> component = new ArrayList<Node>();
+	// do{
+	// n = stack.remove(0);
+	// component.add(n);
+	// }while(n != v);
+	// SCC.add(component);
+	// }
+	// return SCC;
+	// }
 
 	void tarjan(Node v) {
 		v.index = index;
@@ -68,7 +67,7 @@
 			}
 		}
 
-		if (v!=root && v.low == v.index) {
+		if (v != root && v.low == v.index) {
 			Set<T> component = new HashSet<T>();
 			Node n;
 			do {
@@ -80,7 +79,7 @@
 	}
 
 	Set<Set<T>> getResult(Map<T, ? extends Collection<T>> graph) {
-		Map<T, Node> index = new HashMap<T, Node>();
+		Map<T,Node> index = new HashMap<T,Node>();
 
 		for (Map.Entry<T, ? extends Collection<T>> entry : graph.entrySet()) {
 			Node node = getNode(index, entry.getKey());
@@ -92,7 +91,7 @@
 		return scc;
 	}
 
-	private Node getNode(Map<T, Node> index, T key) {
+	private Node getNode(Map<T,Node> index, T key) {
 		Node node = index.get(key);
 		if (node == null) {
 			node = new Node(key);
@@ -101,7 +100,7 @@
 		return node;
 	}
 
-	public static <T> Collection<? extends Collection<T>> tarjan(Map<T, ? extends Collection<T>> graph) {
+	public static <T> Collection< ? extends Collection<T>> tarjan(Map<T, ? extends Collection<T>> graph) {
 		Tarjan<T> tarjan = new Tarjan<T>();
 		return tarjan.getResult(graph);
 	}
diff --git a/bundleplugin/src/main/java/aQute/libg/tuple/Pair.java b/bundleplugin/src/main/java/aQute/libg/tuple/Pair.java
index efb2298..d86d6c8 100644
--- a/bundleplugin/src/main/java/aQute/libg/tuple/Pair.java
+++ b/bundleplugin/src/main/java/aQute/libg/tuple/Pair.java
@@ -1,9 +1,9 @@
 package aQute.libg.tuple;
 
-public class Pair<A,B> {
-	final public A a;
-	final public B b;
-	
+public class Pair<A, B> {
+	final public A	a;
+	final public B	b;
+
 	public Pair(A a, B b) {
 		this.a = a;
 		this.b = b;
diff --git a/bundleplugin/src/main/java/aQute/libg/version/Version.java b/bundleplugin/src/main/java/aQute/libg/version/Version.java
index d326ec4..77d21e4 100755
--- a/bundleplugin/src/main/java/aQute/libg/version/Version.java
+++ b/bundleplugin/src/main/java/aQute/libg/version/Version.java
@@ -3,150 +3,148 @@
 import java.util.regex.*;
 
 public class Version implements Comparable<Version> {
-    final int                   major;
-    final int                   minor;
-    final int                   micro;
-    final String                qualifier;
-    public final static String  VERSION_STRING = "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.([-_\\da-zA-Z]+))?)?)?";
-    public final static Pattern VERSION        = Pattern
-                                                       .compile(VERSION_STRING);
-    public final static Version LOWEST         = new Version();
-    public final static Version HIGHEST        = new Version(Integer.MAX_VALUE,
-                                                       Integer.MAX_VALUE,
-                                                       Integer.MAX_VALUE,
-                                                       "\uFFFF");
+	final int					major;
+	final int					minor;
+	final int					micro;
+	final String				qualifier;
+	public final static String	VERSION_STRING	= "(\\d+)(\\.(\\d+)(\\.(\\d+)(\\.([-_\\da-zA-Z]+))?)?)?";
+	public final static Pattern	VERSION			= Pattern.compile(VERSION_STRING);
+	public final static Version	LOWEST			= new Version();
+	public final static Version	HIGHEST			= new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE,
+														"\uFFFF");
 
-    public static final Version	emptyVersion	= LOWEST;
-    public static final Version	ONE	= new Version(1,0,0);
+	public static final Version	emptyVersion	= LOWEST;
+	public static final Version	ONE				= new Version(1, 0, 0);
 
-    public Version() {
-        this(0);
-    }
+	public Version() {
+		this(0);
+	}
 
-    public Version(int major, int minor, int micro, String qualifier) {
-        this.major = major;
-        this.minor = minor;
-        this.micro = micro;
-        this.qualifier = qualifier;
-    }
+	public Version(int major, int minor, int micro, String qualifier) {
+		this.major = major;
+		this.minor = minor;
+		this.micro = micro;
+		this.qualifier = qualifier;
+	}
 
-    public Version(int major, int minor, int micro) {
-        this(major, minor, micro, null);
-    }
+	public Version(int major, int minor, int micro) {
+		this(major, minor, micro, null);
+	}
 
-    public Version(int major, int minor) {
-        this(major, minor, 0, null);
-    }
+	public Version(int major, int minor) {
+		this(major, minor, 0, null);
+	}
 
-    public Version(int major) {
-        this(major, 0, 0, null);
-    }
+	public Version(int major) {
+		this(major, 0, 0, null);
+	}
 
-    public Version(String version) {
-    	version = version.trim();
-        Matcher m = VERSION.matcher(version);
-        if (!m.matches())
-            throw new IllegalArgumentException("Invalid syntax for version: "
-                    + version);
+	public Version(String version) {
+		version = version.trim();
+		Matcher m = VERSION.matcher(version);
+		if (!m.matches())
+			throw new IllegalArgumentException("Invalid syntax for version: " + version);
 
-        major = Integer.parseInt(m.group(1));
-        if (m.group(3) != null)
-            minor = Integer.parseInt(m.group(3));
-        else
-            minor = 0;
+		major = Integer.parseInt(m.group(1));
+		if (m.group(3) != null)
+			minor = Integer.parseInt(m.group(3));
+		else
+			minor = 0;
 
-        if (m.group(5) != null)
-            micro = Integer.parseInt(m.group(5));
-        else
-            micro = 0;
+		if (m.group(5) != null)
+			micro = Integer.parseInt(m.group(5));
+		else
+			micro = 0;
 
-        qualifier = m.group(7);
-    }
+		qualifier = m.group(7);
+	}
 
-    public int getMajor() {
-        return major;
-    }
+	public int getMajor() {
+		return major;
+	}
 
-    public int getMinor() {
-        return minor;
-    }
+	public int getMinor() {
+		return minor;
+	}
 
-    public int getMicro() {
-        return micro;
-    }
+	public int getMicro() {
+		return micro;
+	}
 
-    public String getQualifier() {
-        return qualifier;
-    }
+	public String getQualifier() {
+		return qualifier;
+	}
 
-    public int compareTo(Version other) {
-        if (other == this)
-            return 0;
+	public int compareTo(Version other) {
+		if (other == this)
+			return 0;
 
-        Version o = other;
-        if (major != o.major)
-            return major - o.major;
+		Version o = other;
+		if (major != o.major)
+			return major - o.major;
 
-        if (minor != o.minor)
-            return minor - o.minor;
+		if (minor != o.minor)
+			return minor - o.minor;
 
-        if (micro != o.micro)
-            return micro - o.micro;
+		if (micro != o.micro)
+			return micro - o.micro;
 
-        int c = 0;
-        if (qualifier != null)
-            c = 1;
-        if (o.qualifier != null)
-            c += 2;
+		int c = 0;
+		if (qualifier != null)
+			c = 1;
+		if (o.qualifier != null)
+			c += 2;
 
-        switch (c) {
-        case 0:
-            return 0;
-        case 1:
-            return 1;
-        case 2:
-            return -1;
-        }
-        return qualifier.compareTo(o.qualifier);
-    }
+		switch (c) {
+			case 0 :
+				return 0;
+			case 1 :
+				return 1;
+			case 2 :
+				return -1;
+		}
+		return qualifier.compareTo(o.qualifier);
+	}
 
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(major);
-        sb.append(".");
-        sb.append(minor);
-        sb.append(".");
-        sb.append(micro);
-        if (qualifier != null) {
-            sb.append(".");
-            sb.append(qualifier);
-        }
-        return sb.toString();
-    }
+	public String toString() {
+		StringBuilder sb = new StringBuilder();
+		sb.append(major);
+		sb.append(".");
+		sb.append(minor);
+		sb.append(".");
+		sb.append(micro);
+		if (qualifier != null) {
+			sb.append(".");
+			sb.append(qualifier);
+		}
+		return sb.toString();
+	}
 
-    public boolean equals(Object ot) {
-        if ( ! (ot instanceof Version))
-            return false;
-        
-        return compareTo((Version)ot) == 0;
-    }
+	public boolean equals(Object ot) {
+		if (!(ot instanceof Version))
+			return false;
 
-    public int hashCode() {
-        return major * 97 ^ minor * 13 ^ micro
-                + (qualifier == null ? 97 : qualifier.hashCode());
-    }
+		return compareTo((Version) ot) == 0;
+	}
 
-    public int get(int i) {
-        switch(i) {
-        case 0 : return major;
-        case 1 : return minor;
-        case 2 : return micro;
-        default:
-            throw new IllegalArgumentException("Version can only get 0 (major), 1 (minor), or 2 (micro)");
-        }
-    }
-    
-    public static Version parseVersion(String version) {
+	public int hashCode() {
+		return major * 97 ^ minor * 13 ^ micro + (qualifier == null ? 97 : qualifier.hashCode());
+	}
+
+	public int get(int i) {
+		switch (i) {
+			case 0 :
+				return major;
+			case 1 :
+				return minor;
+			case 2 :
+				return micro;
+			default :
+				throw new IllegalArgumentException("Version can only get 0 (major), 1 (minor), or 2 (micro)");
+		}
+	}
+
+	public static Version parseVersion(String version) {
 		if (version == null) {
 			return LOWEST;
 		}
@@ -158,9 +156,9 @@
 
 		return new Version(version);
 
-    }
-    
-    public Version getWithoutQualifier() {
-    	return new Version(major,minor,micro);
-    }
+	}
+
+	public Version getWithoutQualifier() {
+		return new Version(major, minor, micro);
+	}
 }
diff --git a/bundleplugin/src/main/java/aQute/libg/version/VersionRange.java b/bundleplugin/src/main/java/aQute/libg/version/VersionRange.java
index 46f9e94..3e00c76 100755
--- a/bundleplugin/src/main/java/aQute/libg/version/VersionRange.java
+++ b/bundleplugin/src/main/java/aQute/libg/version/VersionRange.java
@@ -9,9 +9,8 @@
 	char			start	= '[';
 	char			end		= ']';
 
-	static Pattern	RANGE	= Pattern.compile("(\\(|\\[)\\s*(" +
-									Version.VERSION_STRING + ")\\s*,\\s*(" +
-									Version.VERSION_STRING + ")\\s*(\\)|\\])");
+	static Pattern	RANGE	= Pattern.compile("(\\(|\\[)\\s*(" + Version.VERSION_STRING + ")\\s*,\\s*("
+									+ Version.VERSION_STRING + ")\\s*(\\)|\\])");
 
 	public VersionRange(String string) {
 		string = string.trim();
@@ -24,9 +23,7 @@
 			high = new Version(v2);
 			end = m.group(18).charAt(0);
 			if (low.compareTo(high) > 0)
-				throw new IllegalArgumentException(
-						"Low Range is higher than High Range: " + low + "-" +
-								high);
+				throw new IllegalArgumentException("Low Range is higher than High Range: " + low + "-" + high);
 
 		} else
 			high = low = new Version(string);
@@ -66,8 +63,8 @@
 	}
 
 	public boolean includes(Version v) {
-		if ( !isRange() ) {
-			return low.compareTo(v) <=0;
+		if (!isRange()) {
+			return low.compareTo(v) <= 0;
 		}
 		if (includeLow()) {
 			if (v.compareTo(low) < 0)
@@ -80,17 +77,17 @@
 				return false;
 		} else if (v.compareTo(high) >= 0)
 			return false;
-		
+
 		return true;
 	}
-	
-	public Iterable<Version> filter( final Iterable<Version> versions) {
+
+	public Iterable<Version> filter(final Iterable<Version> versions) {
 		List<Version> list = new ArrayList<Version>();
-		for ( Version v : versions) {
-			if ( includes(v))
+		for (Version v : versions) {
+			if (includes(v))
 				list.add(v);
 		}
 		return list;
 	}
-	
+
 }
\ No newline at end of file
diff --git a/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java b/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java
index ea0fcd0..4d5835b 100644
--- a/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java
+++ b/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java
@@ -9,36 +9,35 @@
 import javax.xml.transform.stream.*;
 
 public class Transform {
-    static TransformerFactory transformerFactory = TransformerFactory
-                                                         .newInstance();
+	static TransformerFactory	transformerFactory	= TransformerFactory.newInstance();
 
-    static Map<URL, Templates> cache          = new ConcurrentHashMap<URL, Templates>();
+	static Map<URL,Templates>	cache				= new ConcurrentHashMap<URL,Templates>();
 
-    public static void transform(TransformerFactory transformerFactory, URL xslt, InputStream in, OutputStream out)
-            throws Exception {
-        if ( xslt == null ) 
-            throw new IllegalArgumentException("No source template specified");
-        
-        Templates templates = cache.get(xslt);
-        if (templates == null) {
-            InputStream xsltIn = xslt.openStream();
-            try {
-                templates = transformerFactory
-                        .newTemplates(new StreamSource(xsltIn));
+	public static void transform(TransformerFactory transformerFactory, URL xslt, InputStream in, OutputStream out)
+			throws Exception {
+		if (xslt == null)
+			throw new IllegalArgumentException("No source template specified");
 
-                cache.put(xslt, templates);
-            } finally {
-                in.close();
-            }
-        }
-        Result xmlResult = new StreamResult(out);
-        Source xmlSource = new StreamSource(in);
-        Transformer t = templates.newTransformer();
-        t.transform(xmlSource, xmlResult);
-        out.flush();
-    }
+		Templates templates = cache.get(xslt);
+		if (templates == null) {
+			InputStream xsltIn = xslt.openStream();
+			try {
+				templates = transformerFactory.newTemplates(new StreamSource(xsltIn));
 
-    public static void transform(URL xslt, InputStream in, OutputStream out) throws Exception {
-        transform(transformerFactory,xslt, in, out);
-    }
+				cache.put(xslt, templates);
+			}
+			finally {
+				in.close();
+			}
+		}
+		Result xmlResult = new StreamResult(out);
+		Source xmlSource = new StreamSource(in);
+		Transformer t = templates.newTransformer();
+		t.transform(xmlSource, xmlResult);
+		out.flush();
+	}
+
+	public static void transform(URL xslt, InputStream in, OutputStream out) throws Exception {
+		transform(transformerFactory, xslt, in, out);
+	}
 }
