diff --git a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/BundleModelElementTest.java b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/BundleModelElementTest.java
index 6ca045f..6aac51c 100644
--- a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/BundleModelElementTest.java
+++ b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/BundleModelElementTest.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core;
 
-
 import java.util.Arrays;
 
 import org.apache.felix.sigil.common.core.internal.model.osgi.BundleModelElement;
@@ -29,82 +28,76 @@
 
 import junit.framework.TestCase;
 
-
 public class BundleModelElementTest extends TestCase
 {
 
-    public BundleModelElementTest( String name )
+    public BundleModelElementTest(String name)
     {
-        super( name );
+        super(name);
     }
 
-
     public void testAddRequires()
     {
         BundleModelElement element = new BundleModelElement();
-        checkRequires( element );
+        checkRequires(element);
     }
 
-
     public void testAddImports()
     {
         BundleModelElement element = new BundleModelElement();
-        checkImports( element );
+        checkImports(element);
     }
 
-
     public void testAddImportsAndRequires()
     {
         BundleModelElement element = new BundleModelElement();
-        checkImports( element );
-        checkRequires( element );
+        checkImports(element);
+        checkRequires(element);
 
         element = new BundleModelElement();
-        checkRequires( element );
-        checkImports( element );
+        checkRequires(element);
+        checkImports(element);
     }
 
-
-    private void checkImports( BundleModelElement element )
+    private void checkImports(BundleModelElement element)
     {
         PackageImport foo = new PackageImport();
-        foo.setPackageName( "foo" );
-        foo.setVersions( VersionRange.parseVersionRange( "1.0.0" ) );
+        foo.setPackageName("foo");
+        foo.setVersions(VersionRange.parseVersionRange("1.0.0"));
         PackageImport bar = new PackageImport();
-        bar.setPackageName( "bar" );
-        bar.setVersions( VersionRange.parseVersionRange( "[2.2.2, 3.3.3]" ) );
+        bar.setPackageName("bar");
+        bar.setVersions(VersionRange.parseVersionRange("[2.2.2, 3.3.3]"));
         PackageImport baz = new PackageImport();
-        baz.setPackageName( "baz" );
-        baz.setVersions( VersionRange.parseVersionRange( "[3.0.0, 4.0.0)" ) );
+        baz.setPackageName("baz");
+        baz.setVersions(VersionRange.parseVersionRange("[3.0.0, 4.0.0)"));
 
-        element.addChild( foo.clone() );
-        element.addChild( bar.clone() );
-        element.addChild( baz.clone() );
+        element.addChild(foo.clone());
+        element.addChild(bar.clone());
+        element.addChild(baz.clone());
 
-        assertTrue( Arrays.asList( element.children() ).contains( foo ) );
-        assertTrue( Arrays.asList( element.children() ).contains( bar ) );
-        assertTrue( Arrays.asList( element.children() ).contains( baz ) );
+        assertTrue(Arrays.asList(element.children()).contains(foo));
+        assertTrue(Arrays.asList(element.children()).contains(bar));
+        assertTrue(Arrays.asList(element.children()).contains(baz));
     }
 
-
-    private void checkRequires( BundleModelElement element )
+    private void checkRequires(BundleModelElement element)
     {
         RequiredBundle foo = new RequiredBundle();
-        foo.setSymbolicName( "foo" );
-        foo.setVersions( VersionRange.parseVersionRange( "1.0.0" ) );
+        foo.setSymbolicName("foo");
+        foo.setVersions(VersionRange.parseVersionRange("1.0.0"));
         RequiredBundle bar = new RequiredBundle();
-        bar.setSymbolicName( "bar" );
-        bar.setVersions( VersionRange.parseVersionRange( "[2.2.2, 3.3.3]" ) );
+        bar.setSymbolicName("bar");
+        bar.setVersions(VersionRange.parseVersionRange("[2.2.2, 3.3.3]"));
         RequiredBundle baz = new RequiredBundle();
-        baz.setSymbolicName( "baz" );
-        baz.setVersions( VersionRange.parseVersionRange( "[3.0.0, 4.0.0)" ) );
+        baz.setSymbolicName("baz");
+        baz.setVersions(VersionRange.parseVersionRange("[3.0.0, 4.0.0)"));
 
-        element.addChild( foo.clone() );
-        element.addChild( bar.clone() );
-        element.addChild( baz.clone() );
+        element.addChild(foo.clone());
+        element.addChild(bar.clone());
+        element.addChild(baz.clone());
 
-        assertTrue( Arrays.asList( element.children() ).contains( foo ) );
-        assertTrue( Arrays.asList( element.children() ).contains( bar ) );
-        assertTrue( Arrays.asList( element.children() ).contains( baz ) );
+        assertTrue(Arrays.asList(element.children()).contains(foo));
+        assertTrue(Arrays.asList(element.children()).contains(bar));
+        assertTrue(Arrays.asList(element.children()).contains(baz));
     }
 }
diff --git a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/ConfigTest.java b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/ConfigTest.java
index ded87b1..35ece3e 100644
--- a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/ConfigTest.java
+++ b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/ConfigTest.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core;
 
-
 import java.io.IOException;
 import java.net.URI;
 import java.util.Collection;
@@ -34,70 +33,70 @@
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.osgi.VersionRange;
 
-
 public class ConfigTest extends TestCase
 {
 
-    static final URI base = URI.create( "test/ConfigTest/sigil.properties" );
+    static final URI base = URI.create("test/ConfigTest/sigil.properties");
 
-    static {
-        System.setProperty( "bar.version", "2.0.0" );        
-    }
-    
-    public ConfigTest( String name )
+    static
     {
-        super( name );
+        System.setProperty("bar.version", "2.0.0");
     }
 
+    public ConfigTest(String name)
+    {
+        super(name);
+    }
 
     public void testSimple() throws IOException
     {
-        IBldProject project = BldFactory.getProject( base.resolve( "test1.properties" ) );
+        IBldProject project = BldFactory.getProject(base.resolve("test1.properties"));
 
         ISigilBundle bundle = project.getDefaultBundle();
         IBundleModelElement info = bundle.getBundleInfo();
 
         PackageImport foo = new PackageImport();
-        foo.setPackageName( "foo" );
-        foo.setVersions( VersionRange.parseVersionRange( "1.0.0" ) );
+        foo.setPackageName("foo");
+        foo.setVersions(VersionRange.parseVersionRange("1.0.0"));
         PackageImport bar = new PackageImport();
-        bar.setPackageName( "bar" );
-        bar.setVersions( VersionRange.parseVersionRange( "[2.2.2, 3.3.3]" ) );
+        bar.setPackageName("bar");
+        bar.setVersions(VersionRange.parseVersionRange("[2.2.2, 3.3.3]"));
         PackageImport baz = new PackageImport();
-        baz.setPackageName( "baz" );
-        baz.setVersions( VersionRange.parseVersionRange( "[3.0.0, 4.0.0)" ) );
+        baz.setPackageName("baz");
+        baz.setVersions(VersionRange.parseVersionRange("[3.0.0, 4.0.0)"));
 
         Collection<IPackageImport> imports = info.getImports();
-        
-        assertTrue( foo.toString(), imports.contains( foo ) );
-        assertTrue( bar.toString(), imports.contains( bar ) );
-        assertTrue( baz.toString(), imports.contains( baz ) );
+
+        assertTrue(foo.toString(), imports.contains(foo));
+        assertTrue(bar.toString(), imports.contains(bar));
+        assertTrue(baz.toString(), imports.contains(baz));
         //IBundleModelElement requirements = project.getRequirements();
     }
-    
-    public void testInherited() throws IOException {
-        
-        IBldProject project = BldFactory.getProject( base.resolve( "inheritance/foo/sigil.properties" ) );
+
+    public void testInherited() throws IOException
+    {
+
+        IBldProject project = BldFactory.getProject(base.resolve("inheritance/foo/sigil.properties"));
 
         ISigilBundle bundle = project.getDefaultBundle();
         IBundleModelElement info = bundle.getBundleInfo();
 
         Collection<IPackageImport> imports = info.getImports();
-        assertEquals( 1, imports.size() );
+        assertEquals(1, imports.size());
         IPackageImport i = imports.iterator().next();
-        assertEquals( "org.bar", i.getPackageName() );
-        assertEquals( VersionRange.parseVersionRange("2.0.0"), i.getVersions() );
-        
-//        project = BldFactory.getProject( base.resolve( "inheritance/foo/sigil.properties" ), true );
-//
-//        bundle = project.getDefaultBundle();
-//        info = bundle.getBundleInfo();
-//
-//        imports = info.getImports();
-//        assertEquals( 1, imports.size() );
-//        i = imports.iterator().next();
-//        assertEquals( "org.bar", i.getPackageName() );
-//        assertEquals( VersionRange.parseVersionRange("2.0.0"), i.getVersions() );
+        assertEquals("org.bar", i.getPackageName());
+        assertEquals(VersionRange.parseVersionRange("2.0.0"), i.getVersions());
+
+        //        project = BldFactory.getProject( base.resolve( "inheritance/foo/sigil.properties" ), true );
+        //
+        //        bundle = project.getDefaultBundle();
+        //        info = bundle.getBundleInfo();
+        //
+        //        imports = info.getImports();
+        //        assertEquals( 1, imports.size() );
+        //        i = imports.iterator().next();
+        //        assertEquals( "org.bar", i.getPackageName() );
+        //        assertEquals( VersionRange.parseVersionRange("2.0.0"), i.getVersions() );
     }
 
 }
diff --git a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExportTest.java b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExportTest.java
index 80bda89..df8a908 100644
--- a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExportTest.java
+++ b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExportTest.java
@@ -25,38 +25,39 @@
 
 public class PackageExportTest extends TestCase
 {
-    public PackageExportTest( String name )
+    public PackageExportTest(String name)
     {
-        super( name );
+        super(name);
     }
 
-    public void testEquals() {
+    public void testEquals()
+    {
         PackageExport p1 = new PackageExport();
         p1.setPackageName("foo");
         p1.setVersion(Version.parseVersion("1.0.0"));
-        
+
         PackageExport p2 = new PackageExport();
         p2.setPackageName("foo");
         p2.setVersion(Version.parseVersion("1.0.0"));
-        
-        assertTrue( p1.equals( p2 ) );
-        assertTrue( p2.equals( p1 ) );
-        
+
+        assertTrue(p1.equals(p2));
+        assertTrue(p2.equals(p1));
+
         PackageExport p3 = new PackageExport();
         p3.setPackageName("foo");
 
-        assertFalse( p1.equals( p3 ) );
-        assertFalse( p3.equals( p1 ) );
-        
+        assertFalse(p1.equals(p3));
+        assertFalse(p3.equals(p1));
+
         PackageExport p4 = new PackageExport();
         p4.setVersion(Version.parseVersion("1.0.0"));
 
-        assertFalse( p1.equals( p4 ) );
-        assertFalse( p4.equals( p1 ) );
-        
+        assertFalse(p1.equals(p4));
+        assertFalse(p4.equals(p1));
+
         PackageExport p5 = new PackageExport();
-        assertFalse( p1.equals( p5 ) );
-        assertFalse( p5.equals( p1 ) );
-        
+        assertFalse(p1.equals(p5));
+        assertFalse(p5.equals(p1));
+
     }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/bnd/BundleBuilder.java b/sigil/common/core/src/org/apache/felix/sigil/common/bnd/BundleBuilder.java
index 199c477..f798037 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/bnd/BundleBuilder.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/bnd/BundleBuilder.java
@@ -179,7 +179,8 @@
         if (bracket >= 0)
         {
             String token = dest.substring(bracket);
-            throw new Exception("destPattern: expected [id],  [name] or [revision]: " + token);
+            throw new Exception("destPattern: expected [id],  [name] or [revision]: "
+                + token);
         }
 
         errors.clear();
@@ -191,7 +192,8 @@
         {
             log.verbose("Generated " + bundle.getSymbolicName());
             log.verbose("-----------------------------");
-            for(Map.Entry<Object, Object> e : spec.entrySet()) {
+            for (Map.Entry<Object, Object> e : spec.entrySet())
+            {
                 log.verbose(e.getKey() + "=" + e.getValue());
                 log.verbose("-----------------------------");
             }
@@ -210,7 +212,7 @@
 
         convertErrors("BND: ", builder.getErrors());
         convertWarnings("BND: ", builder.getWarnings());
-        
+
         Attributes main = jar.getManifest().getMainAttributes();
         String expHeader = main.getValue(Constants.EXPORT_PACKAGE);
         log.verbose("BND exports: " + expHeader);
@@ -455,7 +457,7 @@
             addVersions(fh.getVersions(), sb);
             spec.setProperty(Constants.FRAGMENT_HOST, sb.toString());
         }
-        
+
         return spec;
     }
 
@@ -553,7 +555,7 @@
         {
             if (sb.length() > 0)
                 sb.append(",");
-            
+
             sb.append(bPath.toBNDInstruction(classpath));
         }
 
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldAttr.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldAttr.java
index 76f8444..930fd72 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldAttr.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldAttr.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.config;
 
-
 public class BldAttr
 {
     // Sigil attributes
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConverter.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConverter.java
index e375c3c..84477c5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConverter.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConverter.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.config;
 
-
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -45,7 +44,6 @@
 
 import aQute.lib.osgi.Constants;
 
-
 public class BldConverter
 {
     private static final String classpathFormat = "<classpathentry kind=\"%s\" path=\"%s\"/>";
@@ -53,184 +51,180 @@
     private Properties packageDefaults;
     private TreeSet<String> packageWildDefaults;
 
-
-    public BldConverter( BldConfig config )
+    public BldConverter(BldConfig config)
     {
         this.config = config;
     }
 
-
     /**
      * converts to an ISigilBundle.
      * @param id
      * @param bundle
      * @return
      */
-    public ISigilBundle getBundle( String id, IBldBundle bundle )
+    public ISigilBundle getBundle(String id, IBldBundle bundle)
     {
 
         ISigilBundle sigilBundle = new SigilBundle();
         IBundleModelElement info = new BundleModelElement();
-        sigilBundle.setBundleInfo( info );
+        sigilBundle.setBundleInfo(info);
 
         // exports
         // FIXME: UI doesn't understand export wildcard packages
-        for ( IPackageExport export : bundle.getExports() )
+        for (IPackageExport export : bundle.getExports())
         {
-            IPackageExport clone = ( IPackageExport ) export.clone();
-            clone.setParent( null );
-            info.addExport( clone );
+            IPackageExport clone = (IPackageExport) export.clone();
+            clone.setParent(null);
+            info.addExport(clone);
         }
 
         // imports
-        for ( IPackageImport import1 : bundle.getImports() )
+        for (IPackageImport import1 : bundle.getImports())
         {
-            IPackageImport clone = ( IPackageImport ) import1.clone();
-            clone.setParent( null );
-            info.addImport( clone );
+            IPackageImport clone = (IPackageImport) import1.clone();
+            clone.setParent(null);
+            info.addImport(clone);
         }
 
         // requires
-        for ( IRequiredBundle require : bundle.getRequires() )
+        for (IRequiredBundle require : bundle.getRequires())
         {
-            IRequiredBundle clone = ( IRequiredBundle ) require.clone();
-            clone.setParent( null );
-            info.addRequiredBundle( clone );
+            IRequiredBundle clone = (IRequiredBundle) require.clone();
+            clone.setParent(null);
+            info.addRequiredBundle(clone);
         }
 
         // fragment
         IRequiredBundle fragment = bundle.getFragmentHost();
-        if ( fragment != null )
+        if (fragment != null)
         {
-            info.setFragmentHost( fragment );
+            info.setFragmentHost(fragment);
         }
 
         // contents
-        for ( String pkg : bundle.getContents() )
+        for (String pkg : bundle.getContents())
         {
-            sigilBundle.addPackage( pkg );
+            sigilBundle.addPackage(pkg);
         }
 
         // sources
-        for ( String source : config.getList( null, BldConfig.L_SRC_CONTENTS ) )
+        for (String source : config.getList(null, BldConfig.L_SRC_CONTENTS))
         {
-            sigilBundle.addClasspathEntry( String.format( classpathFormat, "src", source ) );
+            sigilBundle.addClasspathEntry(String.format(classpathFormat, "src", source));
         }
 
         // libs
         Map<String, Map<String, String>> libs = bundle.getLibs();
 
-        for ( String path : libs.keySet() )
+        for (String path : libs.keySet())
         {
-            Map<String, String> attr = libs.get( path );
-            String kind = attr.get( BldAttr.KIND_ATTRIBUTE );
-            
-            if ( "classpath".equals( kind ) )
+            Map<String, String> attr = libs.get(path);
+            String kind = attr.get(BldAttr.KIND_ATTRIBUTE);
+
+            if ("classpath".equals(kind))
             {
-                sigilBundle.addClasspathEntry( String.format( classpathFormat, "lib", path ) );
+                sigilBundle.addClasspathEntry(String.format(classpathFormat, "lib", path));
             }
             else
             {
-                BldCore.error( "Can't convert -libs kind=" + kind );
+                BldCore.error("Can't convert -libs kind=" + kind);
             }
         }
 
         // resources
         // FIXME: UI doesn't support -resources: path1=path2
         List<Resource> resources = bundle.getResources();
-        for ( Resource resource : resources )
+        for (Resource resource : resources)
         {
-            sigilBundle.addSourcePath( resource );
+            sigilBundle.addSourcePath(resource);
         }
 
         ////////////////////
         // simple headers
 
-        info.setSymbolicName( bundle.getSymbolicName() );
+        info.setSymbolicName(bundle.getSymbolicName());
 
-        info.setVersion( VersionTable.getVersion( bundle.getVersion() ) );
+        info.setVersion(VersionTable.getVersion(bundle.getVersion()));
 
         String activator = bundle.getActivator();
-        if ( activator != null )
-            info.setActivator( activator );
+        if (activator != null)
+            info.setActivator(activator);
 
-        Properties headers = config.getProps( id, BldConfig.P_HEADER );
+        Properties headers = config.getProps(id, BldConfig.P_HEADER);
         String header;
 
-        header = headers.getProperty( "CATEGORY" );
-        if ( header != null )
-            info.setCategory( header );
+        header = headers.getProperty("CATEGORY");
+        if (header != null)
+            info.setCategory(header);
 
-        header = headers.getProperty( Constants.BUNDLE_CONTACTADDRESS );
-        if ( header != null )
-            info.setContactAddress( header );
+        header = headers.getProperty(Constants.BUNDLE_CONTACTADDRESS);
+        if (header != null)
+            info.setContactAddress(header);
 
-        header = headers.getProperty( Constants.BUNDLE_COPYRIGHT );
-        if ( header != null )
-            info.setCopyright( header );
+        header = headers.getProperty(Constants.BUNDLE_COPYRIGHT);
+        if (header != null)
+            info.setCopyright(header);
 
-        header = headers.getProperty( Constants.BUNDLE_DESCRIPTION );
-        if ( header != null )
-            info.setDescription( header );
+        header = headers.getProperty(Constants.BUNDLE_DESCRIPTION);
+        if (header != null)
+            info.setDescription(header);
 
-        header = headers.getProperty( Constants.BUNDLE_VENDOR );
-        if ( header != null )
-            info.setVendor( header );
+        header = headers.getProperty(Constants.BUNDLE_VENDOR);
+        if (header != null)
+            info.setVendor(header);
 
-        header = headers.getProperty( Constants.BUNDLE_NAME );
-        if ( header != null )
-            info.setName( header );
+        header = headers.getProperty(Constants.BUNDLE_NAME);
+        if (header != null)
+            info.setName(header);
 
-        header = headers.getProperty( Constants.BUNDLE_DOCURL );
-        if ( header != null )
-            info.setDocURI( URI.create( header ) );
+        header = headers.getProperty(Constants.BUNDLE_DOCURL);
+        if (header != null)
+            info.setDocURI(URI.create(header));
 
-        header = headers.getProperty( Constants.BUNDLE_LICENSE );
-        if ( header != null )
-            info.setDocURI( URI.create( header ) );
+        header = headers.getProperty(Constants.BUNDLE_LICENSE);
+        if (header != null)
+            info.setDocURI(URI.create(header));
 
         return sigilBundle;
     }
 
-
-    private VersionRange defaultVersion( VersionRange current, String defaultRange )
+    private VersionRange defaultVersion(VersionRange current, String defaultRange)
     {
-        if ( current.equals( VersionRange.ANY_VERSION )
-            || current.equals( VersionRange.parseVersionRange( defaultRange ) ) )
+        if (current.equals(VersionRange.ANY_VERSION)
+            || current.equals(VersionRange.parseVersionRange(defaultRange)))
         {
             return null;
         }
         return current;
     }
 
-
     // FIXME - copied from BldProject
-    private String getDefaultPackageVersion( String name )
+    private String getDefaultPackageVersion(String name)
     {
-        if ( packageDefaults == null )
+        if (packageDefaults == null)
         {
-            packageDefaults = config.getProps( null, BldConfig.P_PACKAGE_VERSION );
+            packageDefaults = config.getProps(null, BldConfig.P_PACKAGE_VERSION);
             packageWildDefaults = new TreeSet<String>();
 
-            for ( Object key : packageDefaults.keySet() )
+            for (Object key : packageDefaults.keySet())
             {
-                String pkg = ( String ) key;
-                if ( pkg.endsWith( "*" ) )
+                String pkg = (String) key;
+                if (pkg.endsWith("*"))
                 {
-                    packageWildDefaults.add( pkg.substring( 0, pkg.length() - 1 ) );
+                    packageWildDefaults.add(pkg.substring(0, pkg.length() - 1));
                 }
             }
         }
 
-        String version = packageDefaults.getProperty( name );
+        String version = packageDefaults.getProperty(name);
 
-        if ( version == null )
+        if (version == null)
         {
-            for ( String pkg : packageWildDefaults )
+            for (String pkg : packageWildDefaults)
             {
-                if ( name.startsWith( pkg ) )
+                if (name.startsWith(pkg))
                 {
-                    version = packageDefaults.getProperty( pkg + "*" );
+                    version = packageDefaults.getProperty(pkg + "*");
                     // break; -- don't break, as we want the longest match
                 }
             }
@@ -239,240 +233,238 @@
         return version;
     }
 
-
     /**
      * converts from an ISigilBundle.
      * 
      * @param id
      * @param bundle
      */
-    public void setBundle( String id, ISigilBundle bundle )
+    public void setBundle(String id, ISigilBundle bundle)
     {
         IBundleModelElement info = bundle.getBundleInfo();
-        String bundleVersion = config.getString( id, BldConfig.S_VERSION );
+        String bundleVersion = config.getString(id, BldConfig.S_VERSION);
         Map<String, Map<String, String>> exports = new TreeMap<String, Map<String, String>>();
-        
+
         setSimpleHeaders(id, info);
         setExports(id, bundleVersion, info, exports);
-        
+
         // -imports and -requires are global to all bundles
         setImports(null, bundleVersion, info, exports);
         setRequires(null, bundleVersion, info);
-        
+
         setFragments(id, info);
         setContents(id, info, bundle);
         setLibraries(id, info, bundle);
         setResources(id, info, bundle);
 
-        if ( info.getSourceLocation() != null )
+        if (info.getSourceLocation() != null)
         {
-            BldCore.error( "SourceLocation conversion not yet implemented." );
+            BldCore.error("SourceLocation conversion not yet implemented.");
         }
 
-        if ( !info.getLibraryImports().isEmpty() )
+        if (!info.getLibraryImports().isEmpty())
         {
-            BldCore.error( "LibraryImports conversion not yet implemented." );
+            BldCore.error("LibraryImports conversion not yet implemented.");
         }
     }
 
-
     /**
      * @param id
      * @param info
      */
-    private void setSimpleHeaders( String id, IBundleModelElement info )
+    private void setSimpleHeaders(String id, IBundleModelElement info)
     {
-        List<String> ids = config.getList( null, BldConfig.C_BUNDLES );
-        String idBsn = id != null ? id : ids.get( 0 );
-        String oldBsn = config.getString( id, BldConfig.S_SYM_NAME );
+        List<String> ids = config.getList(null, BldConfig.C_BUNDLES);
+        String idBsn = id != null ? id : ids.get(0);
+        String oldBsn = config.getString(id, BldConfig.S_SYM_NAME);
         String bsn = info.getSymbolicName();
 
-        if ( !bsn.equals( idBsn ) || oldBsn != null )
-            config.setString( id, BldConfig.S_SYM_NAME, bsn );
+        if (!bsn.equals(idBsn) || oldBsn != null)
+            config.setString(id, BldConfig.S_SYM_NAME, bsn);
 
         String version = info.getVersion().toString();
-        if ( version != null )
-            config.setString( id, BldConfig.S_VERSION, version );
+        if (version != null)
+            config.setString(id, BldConfig.S_VERSION, version);
 
         String activator = info.getActivator();
-        if ( activator != null )
-            config.setString( id, BldConfig.S_ACTIVATOR, activator );
+        if (activator != null)
+            config.setString(id, BldConfig.S_ACTIVATOR, activator);
 
-        Properties headers = config.getProps( null, BldConfig.P_HEADER );
+        Properties headers = config.getProps(null, BldConfig.P_HEADER);
 
-        setHeader( headers, id, "CATEGORY", info.getCategory() );
-        setHeader( headers, id, Constants.BUNDLE_CONTACTADDRESS, info.getContactAddress() );
-        setHeader( headers, id, Constants.BUNDLE_COPYRIGHT, info.getCopyright() );
-        setHeader( headers, id, Constants.BUNDLE_DESCRIPTION, info.getDescription() );
-        setHeader( headers, id, Constants.BUNDLE_VENDOR, info.getVendor() );
-        setHeader( headers, id, Constants.BUNDLE_NAME, info.getName() );
+        setHeader(headers, id, "CATEGORY", info.getCategory());
+        setHeader(headers, id, Constants.BUNDLE_CONTACTADDRESS, info.getContactAddress());
+        setHeader(headers, id, Constants.BUNDLE_COPYRIGHT, info.getCopyright());
+        setHeader(headers, id, Constants.BUNDLE_DESCRIPTION, info.getDescription());
+        setHeader(headers, id, Constants.BUNDLE_VENDOR, info.getVendor());
+        setHeader(headers, id, Constants.BUNDLE_NAME, info.getName());
 
-        if ( info.getDocURI() != null )
-            config.setProp( id, BldConfig.P_HEADER, Constants.BUNDLE_DOCURL, info.getDocURI().toString() );
+        if (info.getDocURI() != null)
+            config.setProp(id, BldConfig.P_HEADER, Constants.BUNDLE_DOCURL,
+                info.getDocURI().toString());
 
-        if ( info.getLicenseURI() != null )
-            config.setProp( id, BldConfig.P_HEADER, Constants.BUNDLE_LICENSE, info.getLicenseURI().toString() );
+        if (info.getLicenseURI() != null)
+            config.setProp(id, BldConfig.P_HEADER, Constants.BUNDLE_LICENSE,
+                info.getLicenseURI().toString());
     }
 
-
     /**
      * @param id
      * @param info
      * @param bundle 
      */
-    private void setResources( String id, IBundleModelElement info, ISigilBundle bundle )
+    private void setResources(String id, IBundleModelElement info, ISigilBundle bundle)
     {
         // resources
         ArrayList<String> resources = new ArrayList<String>();
-        for ( Resource ipath : bundle.getSourcePaths() )
+        for (Resource ipath : bundle.getSourcePaths())
         {
-            resources.add( ipath.toString() );
+            resources.add(ipath.toString());
         }
 
-        if ( !resources.isEmpty() || !config.getList( id, BldConfig.L_RESOURCES ).isEmpty() )
+        if (!resources.isEmpty() || !config.getList(id, BldConfig.L_RESOURCES).isEmpty())
         {
-            Collections.sort( resources );
-            config.setList( id, BldConfig.L_RESOURCES, resources );
+            Collections.sort(resources);
+            config.setList(id, BldConfig.L_RESOURCES, resources);
         }
     }
 
-
     /**
      * @param id 
      * @param info
      * @param bundle 
      */
-    private void setLibraries( String id, IBundleModelElement info, ISigilBundle bundle )
+    private void setLibraries(String id, IBundleModelElement info, ISigilBundle bundle)
     {
         // libs
         Map<String, Map<String, String>> libs = new TreeMap<String, Map<String, String>>();
         List<String> sources = new ArrayList<String>();
 
         // classpathEntries map to -libs or -sources
-        for ( String entry : bundle.getClasspathEntrys() )
+        for (String entry : bundle.getClasspathEntrys())
         {
             // <classpathentry kind="lib" path="lib/dependee.jar"/>
             // <classpathentry kind="src" path="src"/>
             final String regex = ".* kind=\"([^\"]+)\" path=\"([^\"]+)\".*";
-            Pattern pattern = Pattern.compile( regex );
-            Matcher matcher = pattern.matcher( entry );
-            if ( matcher.matches() )
+            Pattern pattern = Pattern.compile(regex);
+            Matcher matcher = pattern.matcher(entry);
+            if (matcher.matches())
             {
-                String kind = matcher.group( 1 );
-                String path = matcher.group( 2 );
-                if ( kind.equals( "lib" ) )
+                String kind = matcher.group(1);
+                String path = matcher.group(2);
+                if (kind.equals("lib"))
                 {
                     Map<String, String> map2 = new TreeMap<String, String>();
-                    map2.put( BldAttr.KIND_ATTRIBUTE, "classpath" );
-                    libs.put( path, map2 );
+                    map2.put(BldAttr.KIND_ATTRIBUTE, "classpath");
+                    libs.put(path, map2);
                 }
-                else if ( kind.equals( "src" ) )
+                else if (kind.equals("src"))
                 {
-                    sources.add( path );
+                    sources.add(path);
                 }
                 else
                 {
-                    BldCore.error( "unknown classpathentry kind=" + kind );
+                    BldCore.error("unknown classpathentry kind=" + kind);
                 }
             }
             else
             {
-                BldCore.error( "can't match classpathEntry in: " + entry );
+                BldCore.error("can't match classpathEntry in: " + entry);
             }
         }
 
-        if ( !libs.isEmpty() || !config.getMap( id, BldConfig.M_LIBS ).isEmpty() )
+        if (!libs.isEmpty() || !config.getMap(id, BldConfig.M_LIBS).isEmpty())
         {
-            config.setMap( id, BldConfig.M_LIBS, libs );
+            config.setMap(id, BldConfig.M_LIBS, libs);
         }
 
         // -sourcedirs is global to all bundles
-        if ( !sources.isEmpty() || !config.getList( null, BldConfig.L_SRC_CONTENTS ).isEmpty() )
+        if (!sources.isEmpty()
+            || !config.getList(null, BldConfig.L_SRC_CONTENTS).isEmpty())
         {
-            config.setList( null, BldConfig.L_SRC_CONTENTS, sources );
+            config.setList(null, BldConfig.L_SRC_CONTENTS, sources);
         }
 
     }
 
-
     /**
      * @param id 
      * @param info
      * @param bundle 
      */
-    private void setContents( String id, IBundleModelElement info, ISigilBundle bundle )
+    private void setContents(String id, IBundleModelElement info, ISigilBundle bundle)
     {
         // contents
         List<String> contents = new ArrayList<String>();
-        for ( String pkg : bundle.getPackages() )
+        for (String pkg : bundle.getPackages())
         {
-            contents.add( pkg );
+            contents.add(pkg);
         }
-        if ( !contents.isEmpty() || !config.getList( id, BldConfig.L_CONTENTS ).isEmpty() )
+        if (!contents.isEmpty() || !config.getList(id, BldConfig.L_CONTENTS).isEmpty())
         {
-            config.setList( id, BldConfig.L_CONTENTS, contents );
+            config.setList(id, BldConfig.L_CONTENTS, contents);
         }
     }
 
-
     /**
      * @param id
      * @param info
      */
-    private void setFragments( String id, IBundleModelElement info )
+    private void setFragments(String id, IBundleModelElement info)
     {
-        Properties defaultBundles = config.getProps( null, BldConfig.P_BUNDLE_VERSION );
+        Properties defaultBundles = config.getProps(null, BldConfig.P_BUNDLE_VERSION);
         Map<String, Map<String, String>> fragments = new TreeMap<String, Map<String, String>>();
         IRequiredBundle fragment = info.getFragmentHost();
-        if ( fragment != null )
+        if (fragment != null)
         {
             Map<String, String> map2 = new TreeMap<String, String>();
             String name = fragment.getSymbolicName();
-            VersionRange versions = defaultVersion( fragment.getVersions(), defaultBundles.getProperty( name ) );
-            if ( versions != null )
-                map2.put( BldAttr.VERSION_ATTRIBUTE, versions.toString() );
-            fragments.put( name, map2 );
+            VersionRange versions = defaultVersion(fragment.getVersions(),
+                defaultBundles.getProperty(name));
+            if (versions != null)
+                map2.put(BldAttr.VERSION_ATTRIBUTE, versions.toString());
+            fragments.put(name, map2);
         }
-        if ( !fragments.isEmpty() || !config.getMap( id, BldConfig.M_FRAGMENT ).isEmpty() )
+        if (!fragments.isEmpty() || !config.getMap(id, BldConfig.M_FRAGMENT).isEmpty())
         {
-            config.setMap( id, BldConfig.M_FRAGMENT, fragments );
+            config.setMap(id, BldConfig.M_FRAGMENT, fragments);
         }
     }
 
-
     /**
      * @param id
      * @param bundleVersion
      * @param info
      */
-    private void setRequires( String id, String bundleVersion, IBundleModelElement info )
+    private void setRequires(String id, String bundleVersion, IBundleModelElement info)
     {
         // requires
-        Properties defaultBundles = config.getProps( null, BldConfig.P_BUNDLE_VERSION );
+        Properties defaultBundles = config.getProps(null, BldConfig.P_BUNDLE_VERSION);
         Map<String, Map<String, String>> requires = new TreeMap<String, Map<String, String>>();
 
-        for ( IRequiredBundle require : info.getRequiredBundles() )
+        for (IRequiredBundle require : info.getRequiredBundles())
         {
             Map<String, String> map2 = new TreeMap<String, String>();
             String name = require.getSymbolicName();
-            VersionRange versions = defaultVersion( require.getVersions(), defaultBundles.getProperty( name ) );
-            if ( versions != null )
-                map2.put( BldAttr.VERSION_ATTRIBUTE, versions.toString() );
-            requires.put( name, map2 );
+            VersionRange versions = defaultVersion(require.getVersions(),
+                defaultBundles.getProperty(name));
+            if (versions != null)
+                map2.put(BldAttr.VERSION_ATTRIBUTE, versions.toString());
+            requires.put(name, map2);
         }
-        if ( !requires.isEmpty() || !config.getMap( id, BldConfig.M_REQUIRES ).isEmpty() )
+        if (!requires.isEmpty() || !config.getMap(id, BldConfig.M_REQUIRES).isEmpty())
         {
-            config.setMap( id, BldConfig.M_REQUIRES, requires );
+            config.setMap(id, BldConfig.M_REQUIRES, requires);
         }
     }
 
-
     /**
      * @param bundleVersion 
      * @param info
      * @param exports 
      */
-    private void setImports( String id, String bundleVersion, IBundleModelElement info, Map<String, Map<String, String>> exports )
+    private void setImports(String id, String bundleVersion, IBundleModelElement info,
+        Map<String, Map<String, String>> exports)
     {
         // imports
         Map<String, Map<String, String>> imports = new TreeMap<String, Map<String, String>>();
@@ -481,57 +473,57 @@
         //    if the version to be saved is the same as the default version,
         //    then we should _remove_ the version from the value being saved,
         //    since config.getMap() does not apply default versions.
-        for ( IPackageImport import1 : info.getImports() )
+        for (IPackageImport import1 : info.getImports())
         {
             Map<String, String> map2 = new TreeMap<String, String>();
             String name = import1.getPackageName();
-            VersionRange versions = defaultVersion( import1.getVersions(), getDefaultPackageVersion( name ) );
+            VersionRange versions = defaultVersion(import1.getVersions(),
+                getDefaultPackageVersion(name));
 
             boolean isDependency = import1.isDependency();
-            Map<String, String> selfImport = exports.get( name );
+            Map<String, String> selfImport = exports.get(name);
 
-            if ( selfImport != null )
+            if (selfImport != null)
             {
                 // avoid saving self-import attributes, e.g.
                 // org.cauldron.newton.example.fractal.engine;resolve=auto;version=1.0.0
                 isDependency = true;
 
-                if ( versions != null )
+                if (versions != null)
                 {
-                    String exportVersion = selfImport.get( BldAttr.VERSION_ATTRIBUTE );
-                    if ( exportVersion == null )
+                    String exportVersion = selfImport.get(BldAttr.VERSION_ATTRIBUTE);
+                    if (exportVersion == null)
                         exportVersion = bundleVersion;
 
-                    if ( exportVersion.equals( versions.toString() ) )
+                    if (exportVersion.equals(versions.toString()))
                     {
                         versions = null;
                     }
                 }
             }
 
-            if ( versions != null )
+            if (versions != null)
             {
-                map2.put( BldAttr.VERSION_ATTRIBUTE, versions.toString() );
+                map2.put(BldAttr.VERSION_ATTRIBUTE, versions.toString());
             }
 
-            if ( import1.isOptional() )
+            if (import1.isOptional())
             {
-                map2.put( BldAttr.RESOLUTION_ATTRIBUTE, BldAttr.RESOLUTION_OPTIONAL );
+                map2.put(BldAttr.RESOLUTION_ATTRIBUTE, BldAttr.RESOLUTION_OPTIONAL);
             }
 
-            String resolve = BldProject.getResolve( import1, isDependency );
-            if ( resolve != null )
-                map2.put( BldAttr.RESOLVE_ATTRIBUTE, resolve );
+            String resolve = BldProject.getResolve(import1, isDependency);
+            if (resolve != null)
+                map2.put(BldAttr.RESOLVE_ATTRIBUTE, resolve);
 
-            imports.put( name, map2 );
+            imports.put(name, map2);
         }
-        if ( !imports.isEmpty() || !config.getMap( id, BldConfig.M_IMPORTS ).isEmpty() )
+        if (!imports.isEmpty() || !config.getMap(id, BldConfig.M_IMPORTS).isEmpty())
         {
-            config.setMap( id, BldConfig.M_IMPORTS, imports );
+            config.setMap(id, BldConfig.M_IMPORTS, imports);
         }
     }
 
-
     /**
      * @param id 
      * @param info 
@@ -539,29 +531,29 @@
      * @param exports 
      * 
      */
-    private void setExports(String id, String bundleVersion, IBundleModelElement info, Map<String, Map<String, String>> exports)
+    private void setExports(String id, String bundleVersion, IBundleModelElement info,
+        Map<String, Map<String, String>> exports)
     {
-        for ( IPackageExport export : info.getExports() )
+        for (IPackageExport export : info.getExports())
         {
             Map<String, String> map2 = new TreeMap<String, String>();
             String version = export.getVersion().toString();
-            if ( !version.equals( bundleVersion ) )
-                map2.put( BldAttr.VERSION_ATTRIBUTE, version );
-            exports.put( export.getPackageName(), map2 );
+            if (!version.equals(bundleVersion))
+                map2.put(BldAttr.VERSION_ATTRIBUTE, version);
+            exports.put(export.getPackageName(), map2);
         }
 
-        if ( !exports.isEmpty() || !config.getMap( id, BldConfig.M_EXPORTS ).isEmpty() )
+        if (!exports.isEmpty() || !config.getMap(id, BldConfig.M_EXPORTS).isEmpty())
         {
-            config.setMap( id, BldConfig.M_EXPORTS, exports );
+            config.setMap(id, BldConfig.M_EXPORTS, exports);
         }
     }
 
-
-    private void setHeader( Properties headers, String id, String key, String value )
+    private void setHeader(Properties headers, String id, String key, String value)
     {
-        if ( value == null )
+        if (value == null)
             value = "";
-        if ( !value.equals( headers.getProperty( key, "" ) ) )
-            config.setProp( id, BldConfig.P_HEADER, key, value );
+        if (!value.equals(headers.getProperty(key, "")))
+            config.setProp(id, BldConfig.P_HEADER, key, value);
     }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldFactory.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldFactory.java
index 80eb432..3a9bff8 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldFactory.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldFactory.java
@@ -35,7 +35,8 @@
         return load(uri, false, null);
     }
 
-    public static IBldProject getProject(URI uri, Properties overrides) throws IOException
+    public static IBldProject getProject(URI uri, Properties overrides)
+        throws IOException
     {
         return load(uri, false, overrides);
     }
@@ -67,7 +68,8 @@
         return project;
     }
 
-    private synchronized static BldProject load(URI uri, boolean ignoreCache, Properties overrides) throws IOException
+    private synchronized static BldProject load(URI uri, boolean ignoreCache,
+        Properties overrides) throws IOException
     {
         BldProject p = null;
         if (!ignoreCache)
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
index 7511258..705b2b9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
@@ -180,11 +180,12 @@
             try
             {
                 File file = new File(defaults);
-                if (!file.isAbsolute()) {
+                if (!file.isAbsolute())
+                {
                     file = new File(base, defaults);
                 }
                 file = file.getCanonicalFile();
-                
+
                 URL url = file.toURI().toURL();
                 BldProperties bp = new BldProperties(file.getParentFile(), bldOverrides);
 
@@ -289,23 +290,27 @@
         }
         return file;
     }
-    
-    public Resource newResource(String location) {
+
+    public Resource newResource(String location)
+    {
         String[] paths = location.split("=", 2);
         String bPath = paths[0];
         String fsPath = (paths.length > 1 ? paths[1] : null);
-        if (bPath.startsWith("@")) {
+        if (bPath.startsWith("@"))
+        {
             bPath = bPath.substring(1);
             return new InlineResource(BldProject.this, bPath);
         }
-        else if (bPath.startsWith("{")) {
-            bPath = bPath.substring(1, bPath.length() -1);
+        else if (bPath.startsWith("{"))
+        {
+            bPath = bPath.substring(1, bPath.length() - 1);
             return new PreprocessedResource(BldProject.this, bPath, fsPath);
         }
-        else {
+        else
+        {
             return new StandardResource(BldProject.this, bPath, fsPath);
         }
-    }    
+    }
 
     public String getVersion()
     {
@@ -359,9 +364,9 @@
      * set internal OSGiImport and isDependency flags, based on external
      * resolve= attribute.
      */
-     // OSGiImport:    AUTO    ALWAYS     NEVER
-     // dependency:    default -          compile
-     // !dependency:   auto    runtime    ignore
+    // OSGiImport:    AUTO    ALWAYS     NEVER
+    // dependency:    default -          compile
+    // !dependency:   auto    runtime    ignore
 
     private void setResolve(IPackageImport pi, String resolve) throws IOException
     {
@@ -982,10 +987,11 @@
         public List<Resource> getResources()
         {
             List<String> resources = getList(BldConfig.L_RESOURCES);
-            if (resources == null) {
+            if (resources == null)
+            {
                 return Collections.emptyList();
             }
-            
+
             List<Resource> ret = new ArrayList<Resource>(resources.size());
             for (String resource : resources)
             {
@@ -993,7 +999,7 @@
             }
             return ret;
         }
-        
+
         public Properties getHeaders()
         {
             Properties headers = config.getProps(id, BldConfig.P_HEADER);
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProperties.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProperties.java
index 1ff11e5..a923f31 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProperties.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProperties.java
@@ -39,16 +39,16 @@
     }
 
     private final Properties mySysEnv;
-    
+
     BldProperties(File baseDir, Properties overrides)
     {
         mySysEnv = new Properties(sysEnv);
-        
+
         if (overrides != null)
         {
             mySysEnv.putAll(overrides);
         }
-        
+
         try
         {
             if (baseDir != null)
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/IBldProject.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/IBldProject.java
index d766fae..5db4c5f 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/IBldProject.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/IBldProject.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.config;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -33,54 +32,44 @@
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
 
-
 public interface IBldProject
 {
 
     static final String PROJECT_FILE = "sigil.properties";
     static final String PROJECT_DEFAULTS = "../sigil-defaults.properties";
 
-
     void save() throws IOException;
 
+    void saveAs(File path) throws IOException;
 
-    void saveAs( File path ) throws IOException;
-
-
-    void saveTo( OutputStream out ) throws IOException;
-
+    void saveTo(OutputStream out) throws IOException;
 
     /**
      * gets default package version ranges.
      */
     Properties getDefaultPackageVersions();
 
-
     /**
      * gets default package version range for named package.
      * Also handles wildcards in defaults.
      */
-    String getDefaultPackageVersion( String name );
-
+    String getDefaultPackageVersion(String name);
 
     /**
      * get project options.
      */
     Properties getOptions();
 
-
     /**
      * get project version.
      */
     String getVersion();
 
-
     /**
      * gets dependencies (Package-Import and Require-Bundle) needed to compile.
      */
     IBundleModelElement getDependencies();
 
-
     /**
      * gets project source directories.
      * This is a convenient way to specify bundle contents
@@ -88,55 +77,47 @@
      */
     List<String> getSourceDirs();
 
-
     /**
      * gets the list of packages represented by getSourceDirs().
      * @throws IOException 
      */
     List<String> getSourcePkgs();
 
-
     /**
      * gets bundle ids.
      */
     List<String> getBundleIds();
 
-
     /**
      * gets bundles.
      */
     List<IBldBundle> getBundles();
 
-
     /**
      * convert specified bundle to SigilBundle.
      */
-    ISigilBundle getSigilBundle( String id );
-
+    ISigilBundle getSigilBundle(String id);
 
     /**
      * convert SigilBundle to specified bundle.
      */
-    void setSigilBundle( String id, ISigilBundle sb );
-
+    void setSigilBundle(String id, ISigilBundle sb);
 
     /**
      * converts default bundle to SigilBundle.
      */
     ISigilBundle getDefaultBundle();
 
-
     /**
      * converts SigilBundle to default bundle.
      */
-    void setDefaultBundle( ISigilBundle sb );
-
+    void setDefaultBundle(ISigilBundle sb);
 
     /**
      * resolves a relative path against the project file location.
      */
-    File resolve( String path );
-    
+    File resolve(String path);
+
     /**
      * Creates a new resource for this bundle
      * @param location
@@ -144,7 +125,6 @@
      */
     Resource newResource(String location);
 
-
     /**
      * gets the last modification date of the project file.
      */
@@ -157,80 +137,68 @@
          */
         String getActivator();
 
-
         /**
          * gets bundle id within project.
          */
         String getId();
 
-
         /**
          * gets bundle version.
          */
         String getVersion();
 
-
         /**
          * gets the Bundle-SymbolicName.
          */
         String getSymbolicName();
 
-
         /**
          * gets bundles export-packages.
          */
         List<IPackageExport> getExports();
 
-
         /**
          * gets project import-packages. 
          */
         List<IPackageImport> getImports();
 
-
         /**
          * gets project require-bundles. 
          */
         List<IRequiredBundle> getRequires();
 
-
         /**
          * get bundle fragment-host. 
          */
         IRequiredBundle getFragmentHost();
 
-
         /**
          * gets bundle libs. 
          */
         Map<String, Map<String, String>> getLibs();
 
-
         /**
          * gets the bundle contents
          * @return list of package patterns.
          */
         List<String> getContents();
 
-
         /**
          * gets the additional resources.
          * @return map with key as path in bundle, value as path in file system.
          * Paths are resolved relative to location of project file and also from classpath.
          */
         List<Resource> getResources();
-        
+
         /**
          * gets additional bundle headers.
          */
         Properties getHeaders();
 
-
         /**
          * resolves a relative path against the project file location.
          */
-        File resolve( String path );
-
+        File resolve(String path);
 
         /**
          * @return
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
index 266bce3..39beab2 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
@@ -19,17 +19,14 @@
 
 package org.apache.felix.sigil.common.config;
 
-
 import java.util.Map;
 import java.util.Properties;
 
-
 public interface IRepositoryConfig
 {
     static final String REPOSITORY_PROVIDER = "provider";
     static final String REPOSITORY_LEVEL = "level";
 
-
     /**
      * get properties with which to instantiate repositories.
      * The key REPOSITORY_PROVIDER will be set to the fully qualified class name of the IRepositoryProvider.
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/Resource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/Resource.java
index c0e8b9d..19183a6 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/Resource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/Resource.java
@@ -26,7 +26,7 @@
  *
  */
 public interface Resource
-{  
+{
     String toBNDInstruction(File[] classpath);
 
     /**
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/AbstractResource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/AbstractResource.java
index 21e2305..40d9dba 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/AbstractResource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/AbstractResource.java
@@ -32,18 +32,19 @@
 {
     protected final String bPath;
     protected final IBldProject project;
-    
-    protected AbstractResource(IBldProject project, String bPath) {
-        if (bPath == null) 
+
+    protected AbstractResource(IBldProject project, String bPath)
+    {
+        if (bPath == null)
             throw new NullPointerException();
-        
-        if(project == null)
+
+        if (project == null)
             throw new NullPointerException();
-        
+
         this.bPath = bPath;
         this.project = project;
     }
-    
+
     protected String findFileSystemPath(String fsPath, File[] classpath)
     {
         File resolved = project.resolve(fsPath);
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/InlineResource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/InlineResource.java
index 12d9755..7d23bf5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/InlineResource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/InlineResource.java
@@ -45,8 +45,9 @@
     {
         return bPath;
     }
-    
-    public String toString() {
+
+    public String toString()
+    {
         return '@' + bPath;
     }
 
@@ -57,7 +58,7 @@
     {
         StringBuilder sb = new StringBuilder();
         sb.append('@');
-        
+
         File f = project.resolve(bPath);
 
         if (f.exists())
@@ -66,7 +67,7 @@
         }
         else
             sb.append(bPath);
-        
+
         return sb.toString();
     }
 
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/PreprocessedResource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/PreprocessedResource.java
index 358b1c3..c4672a5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/PreprocessedResource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/PreprocessedResource.java
@@ -30,7 +30,7 @@
 public class PreprocessedResource extends AbstractResource
 {
     private final String fsPath;
-    
+
     public PreprocessedResource(IBldProject project, String bPath, String fsPath)
     {
         super(project, bPath);
@@ -44,13 +44,15 @@
     {
         return fsPath == null ? bPath : fsPath;
     }
-    
+
     @Override
-    public String toString() {
+    public String toString()
+    {
         StringBuilder sb = new StringBuilder();
         sb.append('{');
         sb.append(bPath);
-        if (fsPath != null) {
+        if (fsPath != null)
+        {
             sb.append('=');
             sb.append(fsPath);
         }
@@ -75,7 +77,7 @@
         sb.append('=');
         sb.append(fsp);
         sb.append('}');
-        
+
         return sb.toString();
     }
 
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/StandardResource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/StandardResource.java
index 778f4b9..39c6130 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/StandardResource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/StandardResource.java
@@ -49,12 +49,14 @@
     {
         return fsPath == null ? bPath : fsPath;
     }
-    
+
     @Override
-    public String toString() {
+    public String toString()
+    {
         StringBuilder sb = new StringBuilder();
         sb.append(bPath);
-        if (fsPath != null) {
+        if (fsPath != null)
+        {
             sb.append('=');
             sb.append(fsPath);
         }
@@ -76,7 +78,7 @@
         sb.append(bPath);
         sb.append('=');
         sb.append(fsp);
-        
+
         return sb.toString();
     }
 
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/BldCore.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/BldCore.java
index e80f8d4..d8d6013 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/BldCore.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/BldCore.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core;
 
-
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -43,61 +42,56 @@
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
-
 public class BldCore implements BundleActivator
 {
     private static LicenseManager licenceManager = new LicenseManager();
 
-    private static final Logger log = Logger.getLogger( BldCore.class.getName() );
+    private static final Logger log = Logger.getLogger(BldCore.class.getName());
 
-
-    public static void error( String string, Throwable e )
+    public static void error(String string, Throwable e)
     {
         // TODO 
-        log.log( Level.WARNING, string, e );
+        log.log(Level.WARNING, string, e);
     }
 
-
-    public static void error( String string )
+    public static void error(String string)
     {
-        log.log( Level.WARNING, string );
+        log.log(Level.WARNING, string);
     }
 
-
     public static ILicenseManager getLicenseManager()
     {
         return licenceManager;
     }
 
-
-    public void start( BundleContext context ) throws Exception
+    public void start(BundleContext context) throws Exception
     {
         init();
     }
 
-
     public static void init() throws Exception
     {
-        ModelElementFactory.getInstance().register( ISigilBundle.class, SigilBundle.class, "bundle", "sigil", null );
-        ModelElementFactory.getInstance().register( ILibrary.class, Library.class, "library", "sigil", null );
-        ModelElementFactory.getInstance().register( ILibraryImport.class, LibraryImport.class, "library-import",
-            "sigil", null );
+        ModelElementFactory.getInstance().register(ISigilBundle.class, SigilBundle.class,
+            "bundle", "sigil", null);
+        ModelElementFactory.getInstance().register(ILibrary.class, Library.class,
+            "library", "sigil", null);
+        ModelElementFactory.getInstance().register(ILibraryImport.class,
+            LibraryImport.class, "library-import", "sigil", null);
 
         // osgi elements
-        ModelElementFactory.getInstance().register( IBundleModelElement.class, BundleModelElement.class, "bundle",
-            null, null );
-        ModelElementFactory.getInstance().register( IPackageExport.class, PackageExport.class, "package.export", null,
-            null );
-        ModelElementFactory.getInstance().register( IPackageImport.class, PackageImport.class, "package.import", null,
-            null );
-        ModelElementFactory.getInstance().register( IRequiredBundle.class, RequiredBundle.class, "required.bundle",
-            null, null );
+        ModelElementFactory.getInstance().register(IBundleModelElement.class,
+            BundleModelElement.class, "bundle", null, null);
+        ModelElementFactory.getInstance().register(IPackageExport.class,
+            PackageExport.class, "package.export", null, null);
+        ModelElementFactory.getInstance().register(IPackageImport.class,
+            PackageImport.class, "package.import", null, null);
+        ModelElementFactory.getInstance().register(IRequiredBundle.class,
+            RequiredBundle.class, "required.bundle", null, null);
     }
 
-
-    public void stop( BundleContext context ) throws Exception
+    public void stop(BundleContext context) throws Exception
     {
         // TODO Auto-generated method stub
 
-    }    
+    }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicenseManager.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicenseManager.java
index 7c4ba06..0d6b444 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicenseManager.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicenseManager.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.internal.license;
 
-
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Set;
@@ -28,39 +27,33 @@
 import org.apache.felix.sigil.common.core.licence.ILicenseManager;
 import org.apache.felix.sigil.common.core.licence.ILicensePolicy;
 
-
 public class LicenseManager implements ILicenseManager
 {
 
     private HashMap<String, Pattern> licenses = new HashMap<String, Pattern>();
     private HashMap<String, LicensePolicy> policies = new HashMap<String, LicensePolicy>();
-    private LicensePolicy defaultPolicy = new LicensePolicy( this );
+    private LicensePolicy defaultPolicy = new LicensePolicy(this);
 
-
-    public void addLicense( String name, Pattern pattern )
+    public void addLicense(String name, Pattern pattern)
     {
-        licenses.put( name, pattern );
+        licenses.put(name, pattern);
     }
 
-
-    public void removeLicense( String name )
+    public void removeLicense(String name)
     {
-        licenses.remove( name );
+        licenses.remove(name);
     }
 
-
     public Set<String> getLicenseNames()
     {
-        return Collections.unmodifiableSet( licenses.keySet() );
+        return Collections.unmodifiableSet(licenses.keySet());
     }
 
-
-    public Pattern getLicensePattern( String name )
+    public Pattern getLicensePattern(String name)
     {
-        return licenses.get( name );
+        return licenses.get(name);
     }
 
-
     public ILicensePolicy getDefaultPolicy()
     {
         return defaultPolicy;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicensePolicy.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicensePolicy.java
index 1b3ce5f..d393b0a 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicensePolicy.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicensePolicy.java
@@ -19,45 +19,38 @@
 
 package org.apache.felix.sigil.common.core.internal.license;
 
-
 import org.apache.felix.sigil.common.core.licence.ILicensePolicy;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 import org.eclipse.core.runtime.IProgressMonitor;
 
-
 public class LicensePolicy implements ILicensePolicy
 {
 
     private LicenseManager licenseManager;
 
-
-    public LicensePolicy( LicenseManager licenseManager )
+    public LicensePolicy(LicenseManager licenseManager)
     {
         this.licenseManager = licenseManager;
     }
 
-
-    public boolean accept( ISigilBundle bundle )
+    public boolean accept(ISigilBundle bundle)
     {
         return true;
     }
 
-
-    public void addAllowed( String licenseName )
+    public void addAllowed(String licenseName)
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    public void removeAllowed( String licenseName )
+    public void removeAllowed(String licenseName)
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    public void save( IProgressMonitor monitor )
+    public void save(IProgressMonitor monitor)
     {
         // TODO Auto-generated method stub
 
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/BundleCapability.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/BundleCapability.java
index eb373de..a97d1d2 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/BundleCapability.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/BundleCapability.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- package org.apache.felix.sigil.common.core.internal.model.eclipse;
+package org.apache.felix.sigil.common.core.internal.model.eclipse;
 
 import org.apache.felix.sigil.common.model.AbstractModelElement;
 import org.apache.felix.sigil.common.model.eclipse.IBundleCapability;
@@ -50,15 +50,19 @@
     @Override
     public boolean equals(Object obj)
     {
-        if ( obj == this ) return true;
-        if ( obj == null ) return false;
+        if (obj == this)
+            return true;
+        if (obj == null)
+            return false;
 
-        if ( obj instanceof BundleCapability ) {
+        if (obj instanceof BundleCapability)
+        {
             BundleCapability bc = (BundleCapability) obj;
-            return (bsn == null ? bc.bsn == null : bsn.equals(bc.bsn)) && 
-                (version == null ? bc.version == null : version.equals(bc.version));
+            return (bsn == null ? bc.bsn == null : bsn.equals(bc.bsn))
+                && (version == null ? bc.version == null : version.equals(bc.version));
         }
-        else {
+        else
+        {
             return false;
         }
     }
@@ -67,12 +71,14 @@
     public int hashCode()
     {
         int hc = 11;
-        
-        if ( bsn!= null ) {
+
+        if (bsn != null)
+        {
             hc *= bsn.hashCode();
         }
-        
-        if ( version != null ) {
+
+        if (version != null)
+        {
             hc *= version.hashCode();
         }
 
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/Library.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/Library.java
index 163eaa9..0e16bc5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/Library.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/Library.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.internal.model.eclipse;
 
-
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
@@ -30,7 +29,6 @@
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
 import org.osgi.framework.Version;
 
-
 public class Library extends AbstractCompoundModelElement implements ILibrary
 {
 
@@ -41,70 +39,59 @@
     private Set<IRequiredBundle> bundles;
     private Set<IPackageImport> imports;
 
-
     public Library()
     {
-        super( "Library" );
+        super("Library");
         bundles = new HashSet<IRequiredBundle>();
         imports = new HashSet<IPackageImport>();
     }
 
-
-    public void addBundle( IRequiredBundle bundle )
+    public void addBundle(IRequiredBundle bundle)
     {
-        bundles.add( bundle );
+        bundles.add(bundle);
     }
 
-
-    public void addImport( IPackageImport pi )
+    public void addImport(IPackageImport pi)
     {
-        imports.add( pi );
+        imports.add(pi);
     }
 
-
     public Collection<IRequiredBundle> getBundles()
     {
         return bundles;
     }
 
-
     public Collection<IPackageImport> getImports()
     {
         return imports;
     }
 
-
     public String getName()
     {
         return name;
     }
 
-
     public Version getVersion()
     {
         return version;
     }
 
-
-    public void removeBundle( IRequiredBundle bundle )
+    public void removeBundle(IRequiredBundle bundle)
     {
-        bundles.remove( bundle );
+        bundles.remove(bundle);
     }
 
-
-    public void removeImport( IPackageImport pi )
+    public void removeImport(IPackageImport pi)
     {
-        imports.remove( pi );
+        imports.remove(pi);
     }
 
-
-    public void setName( String name )
+    public void setName(String name)
     {
         this.name = name;
     }
 
-
-    public void setVersion( Version version )
+    public void setVersion(Version version)
     {
         this.version = version;
     }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/LibraryImport.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/LibraryImport.java
index f362a2d..9f2e863 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/LibraryImport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/LibraryImport.java
@@ -19,46 +19,39 @@
 
 package org.apache.felix.sigil.common.core.internal.model.eclipse;
 
-
 import org.apache.felix.sigil.common.model.AbstractModelElement;
 import org.apache.felix.sigil.common.model.eclipse.ILibraryImport;
 import org.apache.felix.sigil.common.osgi.VersionRange;
 
-
 public class LibraryImport extends AbstractModelElement implements ILibraryImport
 {
 
     private static final long serialVersionUID = 1L;
 
-
     public LibraryImport()
     {
-        super( "Library Import" );
+        super("Library Import");
     }
 
     private String libraryName;
     private VersionRange range = VersionRange.ANY_VERSION;
 
-
     public String getLibraryName()
     {
         return libraryName;
     }
 
-
     public VersionRange getVersions()
     {
         return range;
     }
 
-
-    public void setLibraryName( String name )
+    public void setLibraryName(String name)
     {
         this.libraryName = name;
     }
 
-
-    public void setVersions( VersionRange range )
+    public void setVersions(VersionRange range)
     {
         this.range = range;
     }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/SigilBundle.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/SigilBundle.java
index 36fb461..98d1146 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/SigilBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/SigilBundle.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.internal.model.eclipse;
 
-
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -48,7 +47,6 @@
 import org.eclipse.core.runtime.SubMonitor;
 import org.osgi.framework.Version;
 
-
 /**
  * @author dave
  *
@@ -70,106 +68,109 @@
 
     public SigilBundle()
     {
-        super( "Sigil Bundle" );
+        super("Sigil Bundle");
         sourcePaths = new Resource[0];
         classpath = new String[0];
         packages = new String[0];
     }
 
-
-    public void synchronize( IProgressMonitor monitor ) throws IOException
+    public void synchronize(IProgressMonitor monitor) throws IOException
     {
-        SubMonitor progress = SubMonitor.convert( monitor, 100 );
-        progress.subTask( "Synchronizing " + bundle.getSymbolicName() + " binary" );
-        sync( location, bundle.getUpdateLocation(), progress.newChild( 45 ) );
-        
-        if ( bundle.getSourceLocation() != null ) {
+        SubMonitor progress = SubMonitor.convert(monitor, 100);
+        progress.subTask("Synchronizing " + bundle.getSymbolicName() + " binary");
+        sync(location, bundle.getUpdateLocation(), progress.newChild(45));
+
+        if (bundle.getSourceLocation() != null)
+        {
             try
             {
-                progress.subTask( "Synchronizing " + bundle.getSymbolicName() + " source" );
-                sync( sourcePathLocation, bundle.getSourceLocation(), progress.newChild( 45 ) );
+                progress.subTask("Synchronizing " + bundle.getSymbolicName() + " source");
+                sync(sourcePathLocation, bundle.getSourceLocation(),
+                    progress.newChild(45));
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                BldCore.error( "Failed to download source for " + bundle.getSymbolicName() + " " + bundle.getVersion(), e
-                    .getCause() );
+                BldCore.error("Failed to download source for " + bundle.getSymbolicName()
+                    + " " + bundle.getVersion(), e.getCause());
             }
         }
-        
-        if ( bundle.getLicenseURI() != null ) {
+
+        if (bundle.getLicenseURI() != null)
+        {
             try
             {
-                progress.subTask( "Synchronizing " + bundle.getSymbolicName() + " licence" );
-                sync( licencePathLocation, bundle.getLicenseURI(), progress.newChild( 10 ) );
+                progress.subTask("Synchronizing " + bundle.getSymbolicName() + " licence");
+                sync(licencePathLocation, bundle.getLicenseURI(), progress.newChild(10));
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                BldCore.error( "Failed to download licence for " + bundle.getSymbolicName() + " " + bundle.getVersion(), e
-                    .getCause() );
+                BldCore.error("Failed to download licence for "
+                    + bundle.getSymbolicName() + " " + bundle.getVersion(), e.getCause());
             }
         }
-        
+
         updateManifest(location);
     }
 
-
     private void updateManifest(File location) throws IOException
     {
-        if ( location != null ) {
+        if (location != null)
+        {
             JarFile f = new JarFile(location);
-            try {
+            try
+            {
                 setBundleInfo(ManifestUtil.buildBundleModelElement(f.getManifest()));
             }
-            finally {
+            finally
+            {
                 f.close();
             }
         }
     }
 
-
     public boolean isSynchronized()
     {
         return location == null || location.exists();
     }
 
-
-    private static void sync( File local, URI remote, IProgressMonitor monitor ) throws IOException
+    private static void sync(File local, URI remote, IProgressMonitor monitor)
+        throws IOException
     {
         try
         {
-            if ( remote != null )
+            if (remote != null)
             {
-                if ( local != null && !local.exists() )
+                if (local != null && !local.exists())
                 {
                     URL url = remote.toURL();
                     URLConnection connection = url.openConnection();
                     int contentLength = connection.getContentLength();
 
-                    monitor.beginTask( "Downloading from " + url.getHost(), contentLength );
+                    monitor.beginTask("Downloading from " + url.getHost(), contentLength);
 
                     InputStream in = null;
                     OutputStream out = null;
                     try
                     {
                         URLConnection conn = url.openConnection();
-                        if ( conn instanceof HttpURLConnection )
+                        if (conn instanceof HttpURLConnection)
                         {
-                            HttpURLConnection http = ( HttpURLConnection ) conn;
-                            http.setConnectTimeout( 10000 );
-                            http.setReadTimeout( 5000 );
+                            HttpURLConnection http = (HttpURLConnection) conn;
+                            http.setConnectTimeout(10000);
+                            http.setReadTimeout(5000);
                         }
                         in = conn.getInputStream();
                         local.getParentFile().mkdirs();
-                        out = new FileOutputStream( local );
-                        stream( in, out, monitor );
+                        out = new FileOutputStream(local);
+                        stream(in, out, monitor);
                     }
                     finally
                     {
-                        if ( in != null )
+                        if (in != null)
                         {
                             in.close();
                         }
-                        if ( out != null )
+                        if (out != null)
                         {
                             out.close();
                         }
@@ -178,152 +179,137 @@
                 }
             }
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
             local.delete();
             throw e;
         }
     }
 
-
-    private static void stream( InputStream in, OutputStream out, IProgressMonitor monitor ) throws IOException
+    private static void stream(InputStream in, OutputStream out, IProgressMonitor monitor)
+        throws IOException
     {
         byte[] b = new byte[1024];
-        for ( ;; )
+        for (;;)
         {
-            if ( monitor.isCanceled() )
+            if (monitor.isCanceled())
             {
-                throw new InterruptedIOException( "User canceled download" );
+                throw new InterruptedIOException("User canceled download");
             }
-            int r = in.read( b );
-            if ( r == -1 )
+            int r = in.read(b);
+            if (r == -1)
                 break;
-            out.write( b, 0, r );
-            monitor.worked( r );
+            out.write(b, 0, r);
+            monitor.worked(r);
         }
 
         out.flush();
     }
 
-
     public IBundleModelElement getBundleInfo()
     {
         return bundle;
     }
 
-
-    public void setBundleInfo( IBundleModelElement bundle )
+    public void setBundleInfo(IBundleModelElement bundle)
     {
-        if ( bundle == null )
+        if (bundle == null)
         {
-            if ( this.bundle != null )
+            if (this.bundle != null)
             {
-                this.bundle.setParent( null );
+                this.bundle.setParent(null);
             }
         }
         else
         {
-            bundle.setParent( this );
+            bundle.setParent(this);
         }
         this.bundle = bundle;
     }
 
-
-    public void addSourcePath( Resource path )
+    public void addSourcePath(Resource path)
     {
         ArrayList<Resource> tmp = new ArrayList<Resource>(getSourcePaths());
         tmp.add(path);
-        sourcePaths = tmp.toArray( new Resource[tmp.size()] );
+        sourcePaths = tmp.toArray(new Resource[tmp.size()]);
     }
 
-
-    public void removeSourcePath( Resource path )
+    public void removeSourcePath(Resource path)
     {
         ArrayList<Resource> tmp = new ArrayList<Resource>(getSourcePaths());
-        if ( tmp.remove(path) ) {
-            sourcePaths = tmp.toArray( new Resource[tmp.size()] );
+        if (tmp.remove(path))
+        {
+            sourcePaths = tmp.toArray(new Resource[tmp.size()]);
         }
     }
 
-
     public Collection<Resource> getSourcePaths()
     {
         return Arrays.asList(sourcePaths);
     }
 
-
     public void clearSourcePaths()
     {
         sourcePaths = new Resource[0];
     }
 
-
-    public void addClasspathEntry( String encodedClasspath )
+    public void addClasspathEntry(String encodedClasspath)
     {
         ArrayList<String> tmp = new ArrayList<String>(getClasspathEntrys());
         tmp.add(encodedClasspath.trim());
-        classpath = tmp.toArray( new String[tmp.size()] );
+        classpath = tmp.toArray(new String[tmp.size()]);
     }
 
-
     public Collection<String> getClasspathEntrys()
     {
         return Arrays.asList(classpath);
     }
 
-
-    public void removeClasspathEntry( String encodedClasspath )
+    public void removeClasspathEntry(String encodedClasspath)
     {
         ArrayList<String> tmp = new ArrayList<String>(getClasspathEntrys());
-        if ( tmp.remove( encodedClasspath.trim() ) ) {
-            classpath = tmp.toArray( new String[tmp.size()] );
+        if (tmp.remove(encodedClasspath.trim()))
+        {
+            classpath = tmp.toArray(new String[tmp.size()]);
         }
     }
 
-
     public File getLocation()
     {
         return location;
     }
 
-
-    public void setLocation( File location )
+    public void setLocation(File location)
     {
         this.location = location;
     }
 
-
     public File getSourcePathLocation()
     {
         return sourcePathLocation;
     }
 
-
-    public void setSourcePathLocation( File location )
+    public void setSourcePathLocation(File location)
     {
         this.sourcePathLocation = location;
     }
 
-
     public String getSourceRootPath()
     {
         return sourceRootPath;
     }
 
-
-    public void setSourceRootPath( String location )
+    public void setSourceRootPath(String location)
     {
         this.sourceRootPath = location;
     }
 
-
     public File getLicencePathLocation()
     {
         return licencePathLocation;
     }
 
-
-    public void setLicencePathLocation( File licencePathLocation )
+    public void setLicencePathLocation(File licencePathLocation)
     {
         this.licencePathLocation = licencePathLocation;
     }
@@ -333,57 +319,52 @@
         return bundle.getSymbolicName();
     }
 
-
     public Version getVersion()
     {
         return bundle.getVersion();
     }
 
-
-    public void setVersion( Version version )
+    public void setVersion(Version version)
     {
-        this.bundle.setVersion( version );
+        this.bundle.setVersion(version);
     }
 
-
     public String getSymbolicName()
     {
         return bundle.getSymbolicName();
     }
 
-
     public Collection<String> getPackages()
     {
         return Arrays.asList(packages);
     }
 
-
-    public void addPackage( String pkg )
+    public void addPackage(String pkg)
     {
         ArrayList<String> tmp = new ArrayList<String>(getClasspathEntrys());
         tmp.add(pkg);
-        packages = tmp.toArray( new String[tmp.size()] );
+        packages = tmp.toArray(new String[tmp.size()]);
     }
 
-
-    public boolean removePackage( String pkg )
+    public boolean removePackage(String pkg)
     {
         ArrayList<String> tmp = new ArrayList<String>(getClasspathEntrys());
-        if ( tmp.remove(pkg) ) {
-            packages = tmp.toArray( new String[tmp.size()] );
+        if (tmp.remove(pkg))
+        {
+            packages = tmp.toArray(new String[tmp.size()]);
             return true;
         }
-        else {
+        else
+        {
             return false;
         }
     }
 
-
-    public IPackageExport findExport( String packageName )
+    public IPackageExport findExport(String packageName)
     {
-        for ( IPackageExport e : bundle.getExports() )
+        for (IPackageExport e : bundle.getExports())
         {
-            if ( packageName.equals( e.getPackageName() ) )
+            if (packageName.equals(e.getPackageName()))
             {
                 return e;
             }
@@ -391,45 +372,43 @@
         return null;
     }
 
-
-    public IPackageImport findImport( String packageName )
+    public IPackageImport findImport(String packageName)
     {
-        for ( IPackageImport i : bundle.getImports() )
+        for (IPackageImport i : bundle.getImports())
         {
-            if ( packageName.equals( i.getPackageName() ) )
+            if (packageName.equals(i.getPackageName()))
             {
                 return i;
             }
         }
         return null;
     }
-    
+
     @Override
     public String toString()
     {
         return "SigilBundle["
-            + ( getBundleInfo() == null ? null : ( getBundleInfo().getSymbolicName() + ":" + getBundleInfo()
-                .getVersion() ) ) + "]";
+            + (getBundleInfo() == null ? null
+                : (getBundleInfo().getSymbolicName() + ":" + getBundleInfo().getVersion()))
+            + "]";
     }
 
-
     @Override
-    public boolean equals( Object obj )
+    public boolean equals(Object obj)
     {
-        if ( obj == null )
+        if (obj == null)
             return false;
-        if ( obj == this )
+        if (obj == this)
             return true;
 
-        if ( obj instanceof SigilBundle )
+        if (obj instanceof SigilBundle)
         {
-            return obj.toString().equals( toString() );
+            return obj.toString().equals(toString());
         }
 
         return false;
     }
 
-
     @Override
     public int hashCode()
     {
@@ -441,15 +420,15 @@
     {
         SigilBundle b = (SigilBundle) super.clone();
         b.bundle = (IBundleModelElement) b.bundle.clone();
-        
+
         Resource[] newPaths = new Resource[b.sourcePaths.length];
         System.arraycopy(b.sourcePaths, 0, newPaths, 0, b.sourcePaths.length);
         b.sourcePaths = newPaths;
-        
+
         String[] tmp = new String[classpath.length];
         System.arraycopy(b.classpath, 0, tmp, 0, b.classpath.length);
         b.classpath = tmp;
-        
+
         tmp = new String[packages.length];
         System.arraycopy(b.packages, 0, tmp, 0, b.packages.length);
         b.packages = tmp;
@@ -457,9 +436,8 @@
         return b;
     }
 
-
     public IBundleCapability getBundleCapability()
     {
         return new BundleCapability(bundle);
-    }    
+    }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/BundleModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/BundleModelElement.java
index c3febc7..de31c2d 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/BundleModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/BundleModelElement.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.internal.model.osgi;
 
-
 import java.net.URI;
 import java.util.Arrays;
 import java.util.Collection;
@@ -36,7 +35,6 @@
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
 import org.osgi.framework.Version;
 
-
 public class BundleModelElement extends AbstractCompoundModelElement implements IBundleModelElement
 {
     /**
@@ -68,10 +66,9 @@
     private String activator;
     private Set<ILibraryImport> libraries;
 
-
     public BundleModelElement()
     {
-        super( "OSGi Bundle" );
+        super("OSGi Bundle");
         this.imports = new IPackageImport[0];
         this.exports = new IPackageExport[0];
         this.requires = new IRequiredBundle[0];
@@ -79,337 +76,301 @@
         this.libraries = new HashSet<ILibraryImport>();
     }
 
-
     public String getActivator()
     {
         return activator;
     }
 
-
-    public void setActivator( String activator )
+    public void setActivator(String activator)
     {
         this.activator = activator;
     }
 
-
-    public void addLibraryImport( ILibraryImport library )
+    public void addLibraryImport(ILibraryImport library)
     {
-        libraries.add( library );
+        libraries.add(library);
     }
 
-
     public Set<ILibraryImport> getLibraryImports()
     {
         return libraries;
     }
 
-
-    public void removeLibraryImport( ILibraryImport library )
+    public void removeLibraryImport(ILibraryImport library)
     {
-        libraries.remove( library );
+        libraries.remove(library);
     }
 
-
     public String getCategory()
     {
         return category;
     }
 
-
-    public void setCategory( String category )
+    public void setCategory(String category)
     {
         this.category = category;
     }
 
-
     public String getContactAddress()
     {
         return contactAddress;
     }
 
-
-    public void setContactAddress( String contactAddress )
+    public void setContactAddress(String contactAddress)
     {
         this.contactAddress = contactAddress;
     }
 
-
     public String getCopyright()
     {
         return copyright;
     }
 
-
-    public void setCopyright( String copyright )
+    public void setCopyright(String copyright)
     {
         this.copyright = copyright;
     }
 
-
     public URI getDocURI()
     {
         return docURI;
     }
 
-
-    public void setDocURI( URI docURI )
+    public void setDocURI(URI docURI)
     {
         this.docURI = docURI;
     }
 
-
     public Collection<IPackageExport> getExports()
     {
         return Arrays.asList(exports);
     }
 
-
-    public void addExport( IPackageExport packageExport )
+    public void addExport(IPackageExport packageExport)
     {
         HashSet<IPackageExport> tmp = new HashSet<IPackageExport>(getExports());
-        if ( tmp.add(packageExport) ) {
-            exports = tmp.toArray( new IPackageExport[tmp.size()] );
-            packageExport.setParent( this );
+        if (tmp.add(packageExport))
+        {
+            exports = tmp.toArray(new IPackageExport[tmp.size()]);
+            packageExport.setParent(this);
         }
     }
 
-    public void removeExport( IPackageExport packageExport )
+    public void removeExport(IPackageExport packageExport)
     {
         HashSet<IPackageExport> tmp = new HashSet<IPackageExport>(getExports());
-        if ( tmp.remove(packageExport) ) {
-            exports = tmp.toArray( new IPackageExport[tmp.size()] );
-            packageExport.setParent( null );
+        if (tmp.remove(packageExport))
+        {
+            exports = tmp.toArray(new IPackageExport[tmp.size()]);
+            packageExport.setParent(null);
         }
     }
 
-
     public Collection<IPackageImport> getImports()
     {
         return Arrays.asList(imports);
     }
 
-
-    public void addImport( IPackageImport packageImport )
+    public void addImport(IPackageImport packageImport)
     {
         HashSet<IPackageImport> tmp = new HashSet<IPackageImport>(getImports());
-        if ( tmp.add(packageImport) ) {
-            imports = tmp.toArray( new IPackageImport[tmp.size()] );
-            packageImport.setParent( this );
+        if (tmp.add(packageImport))
+        {
+            imports = tmp.toArray(new IPackageImport[tmp.size()]);
+            packageImport.setParent(this);
         }
     }
 
-
-    public void removeImport( IPackageImport packageImport )
+    public void removeImport(IPackageImport packageImport)
     {
         HashSet<IPackageImport> tmp = new HashSet<IPackageImport>(getImports());
-        if ( tmp.remove(packageImport) ) {
-            imports = tmp.toArray( new IPackageImport[tmp.size()] );
-            packageImport.setParent( null );
+        if (tmp.remove(packageImport))
+        {
+            imports = tmp.toArray(new IPackageImport[tmp.size()]);
+            packageImport.setParent(null);
         }
     }
 
-
     public Collection<IRequiredBundle> getRequiredBundles()
     {
         return Arrays.asList(requires);
     }
 
-
-    public void addRequiredBundle( IRequiredBundle bundle )
+    public void addRequiredBundle(IRequiredBundle bundle)
     {
         HashSet<IRequiredBundle> tmp = new HashSet<IRequiredBundle>(getRequiredBundles());
-        if ( tmp.add(bundle) ) {
-            requires = tmp.toArray( new IRequiredBundle[tmp.size()] );
-            bundle.setParent( this );
+        if (tmp.add(bundle))
+        {
+            requires = tmp.toArray(new IRequiredBundle[tmp.size()]);
+            bundle.setParent(this);
         }
     }
 
-
-    public void removeRequiredBundle( IRequiredBundle bundle )
+    public void removeRequiredBundle(IRequiredBundle bundle)
     {
         HashSet<IRequiredBundle> tmp = new HashSet<IRequiredBundle>(getRequiredBundles());
-        if ( tmp.remove(bundle) ) {
-            requires = tmp.toArray( new IRequiredBundle[tmp.size()] );
-            bundle.setParent( null );
+        if (tmp.remove(bundle))
+        {
+            requires = tmp.toArray(new IRequiredBundle[tmp.size()]);
+            bundle.setParent(null);
         }
     }
 
-
     public URI getLicenseURI()
     {
         return licenseURI;
     }
 
-
-    public void setLicenseURI( URI licenseURI )
+    public void setLicenseURI(URI licenseURI)
     {
         this.licenseURI = licenseURI;
     }
 
-
     public URI getSourceLocation()
     {
         return sourceLocation;
     }
 
-
-    public void setSourceLocation( URI sourceLocation )
+    public void setSourceLocation(URI sourceLocation)
     {
         this.sourceLocation = sourceLocation;
     }
 
-
     public String getSymbolicName()
     {
         return symbolicName;
     }
 
-
-    public void setSymbolicName( String symbolicName )
+    public void setSymbolicName(String symbolicName)
     {
         this.symbolicName = symbolicName == null ? null : symbolicName.intern();
     }
 
-
     public URI getUpdateLocation()
     {
         return updateLocation;
     }
 
-
-    public void setUpdateLocation( URI updateLocation )
+    public void setUpdateLocation(URI updateLocation)
     {
         this.updateLocation = updateLocation;
     }
 
-
     public String getVendor()
     {
         return vendor;
     }
 
-
-    public void setVendor( String vendor )
+    public void setVendor(String vendor)
     {
         this.vendor = vendor;
     }
 
-
     public Version getVersion()
     {
         return version;
     }
 
-
-    public void setVersion( Version version )
+    public void setVersion(Version version)
     {
         this.version = version == null ? Version.emptyVersion : version;
     }
 
-
     public void checkValid() throws InvalidModelException
     {
-        if ( symbolicName == null )
-            throw new InvalidModelException( this, "Bundle symbolic name not set" );
+        if (symbolicName == null)
+            throw new InvalidModelException(this, "Bundle symbolic name not set");
     }
 
-
     public BundleModelElement clone()
     {
-        BundleModelElement bd = ( BundleModelElement ) super.clone();
+        BundleModelElement bd = (BundleModelElement) super.clone();
 
         bd.imports = new IPackageImport[imports.length];
         bd.exports = new IPackageExport[exports.length];
         bd.requires = new IRequiredBundle[requires.length];
 
-        for ( int i = 0; i < imports.length; i++ ) 
+        for (int i = 0; i < imports.length; i++)
         {
             bd.imports[i] = (IPackageImport) imports[i].clone();
         }
 
-        for ( int i = 0; i < exports.length; i++ )
+        for (int i = 0; i < exports.length; i++)
         {
-            bd.exports[i] = ( IPackageExport ) exports[i].clone();
+            bd.exports[i] = (IPackageExport) exports[i].clone();
         }
 
-        for ( int i = 0; i < requires.length; i++ )
+        for (int i = 0; i < requires.length; i++)
         {
-            bd.requires[i] = ( IRequiredBundle ) requires[i].clone();
+            bd.requires[i] = (IRequiredBundle) requires[i].clone();
         }
 
         return bd;
     }
 
-
     public String toString()
     {
         StringBuffer buf = new StringBuffer();
 
-        buf.append( "BundleModelElement[" );
-        buf.append( symbolicName );
-        buf.append( ", " );
-        buf.append( version );
-        buf.append( "]" );
+        buf.append("BundleModelElement[");
+        buf.append(symbolicName);
+        buf.append(", ");
+        buf.append(version);
+        buf.append("]");
 
         return buf.toString();
     }
 
-
     public String getName()
     {
         return name;
     }
 
-
-    public void setName( String name )
+    public void setName(String name)
     {
         this.name = name;
     }
 
-
     public String getDescription()
     {
         return description;
     }
 
-
-    public void setDescription( String description )
+    public void setDescription(String description)
     {
         this.description = description;
     }
 
-
-    public void addClasspath( String path )
+    public void addClasspath(String path)
     {
         HashSet<String> tmp = new HashSet<String>(Arrays.asList(classpathElements));
-        if ( tmp.add(path) ) {
-            classpathElements = tmp.toArray( new String[tmp.size()] );
+        if (tmp.add(path))
+        {
+            classpathElements = tmp.toArray(new String[tmp.size()]);
         }
     }
 
-
     public Collection<String> getClasspaths()
     {
-        return classpathElements.length == 0 ? Collections.singleton( "." ) : Arrays.asList(classpathElements);
+        return classpathElements.length == 0 ? Collections.singleton(".")
+            : Arrays.asList(classpathElements);
     }
 
-
-    public void removeClasspath( String path )
+    public void removeClasspath(String path)
     {
         HashSet<String> tmp = new HashSet<String>(Arrays.asList(classpathElements));
-        if ( tmp.remove(path) ) {
-            classpathElements = tmp.toArray( new String[tmp.size()] );
+        if (tmp.remove(path))
+        {
+            classpathElements = tmp.toArray(new String[tmp.size()]);
         }
     }
 
-
     public IRequiredBundle getFragmentHost()
     {
         return fragmentHost;
     }
 
-
-    public void setFragmentHost( IRequiredBundle fragmentHost )
+    public void setFragmentHost(IRequiredBundle fragmentHost)
     {
         this.fragmentHost = fragmentHost;
     }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExport.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExport.java
index 8b70562..88efb5e 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExport.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.internal.model.osgi;
 
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -29,7 +28,6 @@
 import org.apache.felix.sigil.common.model.osgi.IPackageExport;
 import org.osgi.framework.Version;
 
-
 public class PackageExport extends AbstractModelElement implements IPackageExport
 {
 
@@ -41,33 +39,30 @@
 
     public PackageExport()
     {
-        super( "OSGi Package Export" );
+        super("OSGi Package Export");
     }
 
-
     public String getPackageName()
     {
         return name;
     }
 
-
-    public void setPackageName( String packageName )
+    public void setPackageName(String packageName)
     {
         this.name = packageName;
     }
 
-
     public Version getVersion()
     {
         Version result;
-        if ( version != null )
+        if (version != null)
         {
             result = version;
         }
         else
         {
-            ISigilBundle owningBundle = getAncestor( ISigilBundle.class );
-            if ( owningBundle == null )
+            ISigilBundle owningBundle = getAncestor(ISigilBundle.class);
+            if (owningBundle == null)
             {
                 result = Version.emptyVersion;
             }
@@ -79,73 +74,64 @@
         return result;
     }
 
-
     public Version getRawVersion()
     {
         return version;
     }
 
-
-    public void setVersion( Version version )
+    public void setVersion(Version version)
     {
         this.version = version; // == null ? Version.emptyVersion : version;
     }
 
-
-    public void addUse( String use )
+    public void addUse(String use)
     {
         ArrayList<String> tmp = new ArrayList<String>(getUses());
         tmp.add(use);
-        uses = tmp.toArray( new String[tmp.size()] );
+        uses = tmp.toArray(new String[tmp.size()]);
     }
 
-
     public Collection<String> getUses()
     {
         return Arrays.asList(uses);
     }
 
-
-    public void removeUse( String use )
+    public void removeUse(String use)
     {
         ArrayList<String> tmp = new ArrayList<String>(getUses());
         tmp.remove(use);
-        uses = tmp.toArray( new String[tmp.size()] );
+        uses = tmp.toArray(new String[tmp.size()]);
     }
 
-
     @Override
     public String toString()
     {
         return "PackageExport[" + name + ":" + version + ":uses=" + uses + "]";
     }
 
-
-    public void setUses( Collection<String> uses )
+    public void setUses(Collection<String> uses)
     {
         ArrayList<String> tmp = new ArrayList<String>(uses);
-        this.uses = tmp.toArray( new String[tmp.size()] );
+        this.uses = tmp.toArray(new String[tmp.size()]);
     }
 
-
-    public int compareTo( IPackageExport o )
+    public int compareTo(IPackageExport o)
     {
-        int i = name.compareTo( o.getPackageName() );
+        int i = name.compareTo(o.getPackageName());
 
-        if ( i == 0 )
+        if (i == 0)
         {
-            i = compareVersion( o.getVersion() );
+            i = compareVersion(o.getVersion());
         }
 
         return i;
     }
 
-
-    private int compareVersion( Version other )
+    private int compareVersion(Version other)
     {
-        if ( version == null )
+        if (version == null)
         {
-            if ( other == null )
+            if (other == null)
             {
                 return 0;
             }
@@ -156,44 +142,45 @@
         }
         else
         {
-            if ( other == null )
+            if (other == null)
             {
                 return -1;
             }
             else
             {
-                return version.compareTo( other );
+                return version.compareTo(other);
             }
         }
     }
 
-
     @Override
     public boolean equals(Object obj)
     {
-        if ( obj == this ) return true;
-        if ( obj == null ) return false;
-        
-        if ( obj instanceof PackageExport ) 
+        if (obj == this)
+            return true;
+        if (obj == null)
+            return false;
+
+        if (obj instanceof PackageExport)
         {
             PackageExport e = (PackageExport) obj;
-            return (name == null ? e.name == null : name.equals( e.name )) && 
-                (version == null ? e.version == null : version.equals( e.version ));
+            return (name == null ? e.name == null : name.equals(e.name))
+                && (version == null ? e.version == null : version.equals(e.version));
         }
-        else 
+        else
         {
             return false;
         }
     }
 
-
     @Override
     public int hashCode()
     {
         int hc = name.hashCode();
-        
-        if ( version != null ) hc *= version.hashCode();
-        
+
+        if (version != null)
+            hc *= version.hashCode();
+
         return hc;
     }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageImport.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageImport.java
index 5d988de..4d5ea93 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageImport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageImport.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.internal.model.osgi;
 
-
 import org.apache.felix.sigil.common.model.AbstractModelElement;
 import org.apache.felix.sigil.common.model.ICapabilityModelElement;
 import org.apache.felix.sigil.common.model.InvalidModelException;
@@ -27,7 +26,6 @@
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.osgi.VersionRange;
 
-
 public class PackageImport extends AbstractModelElement implements IPackageImport
 {
 
@@ -41,102 +39,90 @@
     private boolean dependency = true;
     private OSGiImport osgiImport = OSGiImport.AUTO;
 
-
     public PackageImport()
     {
-        super( "OSGi Package Import" );
+        super("OSGi Package Import");
     }
 
-
     @Override
     public void checkValid() throws InvalidModelException
     {
-        if ( name == null )
+        if (name == null)
         {
-            throw new InvalidModelException( this, "Package name must be set" );
+            throw new InvalidModelException(this, "Package name must be set");
         }
     }
 
-
     public boolean isOptional()
     {
         return optional;
     }
 
-
-    public void setOptional( boolean optional )
+    public void setOptional(boolean optional)
     {
         this.optional = optional;
     }
 
-
     public boolean isDependency()
     {
         return dependency;
     }
 
-
-    public void setDependency( boolean dependency )
+    public void setDependency(boolean dependency)
     {
         this.dependency = dependency;
     }
 
-
     public OSGiImport getOSGiImport()
     {
         return osgiImport;
     }
 
-
-    public void setOSGiImport( OSGiImport osgiHeader )
+    public void setOSGiImport(OSGiImport osgiHeader)
     {
         this.osgiImport = osgiHeader;
     }
 
-
     public String getPackageName()
     {
         return name;
     }
 
-
-    public void setPackageName( String name )
+    public void setPackageName(String name)
     {
         this.name = name;
     }
 
-
     public VersionRange getVersions()
     {
         return versions;
     }
 
-
-    public void setVersions( VersionRange versions )
+    public void setVersions(VersionRange versions)
     {
         this.versions = versions == null ? VersionRange.ANY_VERSION : versions;
     }
 
-
     @Override
     public String toString()
     {
-        return "Package-Import[" + name + ":" + versions + ":" + ( optional ? "optional" : "mandatory" ) + "]";
+        return "Package-Import[" + name + ":" + versions + ":"
+            + (optional ? "optional" : "mandatory") + "]";
     }
 
-
     @Override
-    public boolean equals( Object obj )
+    public boolean equals(Object obj)
     {
-        if ( this == obj )
+        if (this == obj)
             return true;
-        if ( obj == null )
+        if (obj == null)
             return false;
 
-        if ( obj instanceof PackageImport )
+        if (obj instanceof PackageImport)
         {
-            PackageImport pi = ( PackageImport ) obj;
-            return name.equals( pi.name ) && versions.equals( pi.versions ) && optional == pi.optional;
+            PackageImport pi = (PackageImport) obj;
+            return name.equals(pi.name) && versions.equals(pi.versions)
+                && optional == pi.optional;
         }
         else
         {
@@ -144,13 +130,12 @@
         }
     }
 
-
     @Override
     public int hashCode()
     {
         int hc = name.hashCode() * versions.hashCode();
 
-        if ( optional )
+        if (optional)
         {
             hc *= -1;
         }
@@ -158,13 +143,12 @@
         return hc;
     }
 
-
-    public boolean accepts( ICapabilityModelElement provider )
+    public boolean accepts(ICapabilityModelElement provider)
     {
-        if ( provider instanceof IPackageExport )
+        if (provider instanceof IPackageExport)
         {
-            IPackageExport pe = ( IPackageExport ) provider;
-            return pe.getPackageName().equals( name ) && versions.contains( pe.getVersion() );
+            IPackageExport pe = (IPackageExport) provider;
+            return pe.getPackageName().equals(name) && versions.contains(pe.getVersion());
         }
         else
         {
@@ -172,25 +156,23 @@
         }
     }
 
-
-    public int compareTo( IPackageImport o )
+    public int compareTo(IPackageImport o)
     {
-        int i = name.compareTo( o.getPackageName() );
+        int i = name.compareTo(o.getPackageName());
 
-        if ( i == 0 )
+        if (i == 0)
         {
-            i = compareVersion( o.getVersions() );
+            i = compareVersion(o.getVersions());
         }
 
         return i;
     }
 
-
-    private int compareVersion( VersionRange range )
+    private int compareVersion(VersionRange range)
     {
-        if ( versions == null )
+        if (versions == null)
         {
-            if ( range == null )
+            if (range == null)
             {
                 return 0;
             }
@@ -201,13 +183,13 @@
         }
         else
         {
-            if ( range == null )
+            if (range == null)
             {
                 return -1;
             }
             else
             {
-                return versions.getCeiling().compareTo( range.getCeiling() );
+                return versions.getCeiling().compareTo(range.getCeiling());
             }
         }
     }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/RequiredBundle.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/RequiredBundle.java
index e64c284a..187e040 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/RequiredBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/RequiredBundle.java
@@ -19,14 +19,12 @@
 
 package org.apache.felix.sigil.common.core.internal.model.osgi;
 
-
 import org.apache.felix.sigil.common.model.AbstractModelElement;
 import org.apache.felix.sigil.common.model.ICapabilityModelElement;
 import org.apache.felix.sigil.common.model.eclipse.IBundleCapability;
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
 import org.apache.felix.sigil.common.osgi.VersionRange;
 
-
 public class RequiredBundle extends AbstractModelElement implements IRequiredBundle
 {
     private static final long serialVersionUID = 1L;
@@ -35,68 +33,61 @@
     private VersionRange versions = VersionRange.ANY_VERSION;
     private boolean optional;
 
-
     public RequiredBundle()
     {
-        super( "OSGi Bundle Requirement" );
+        super("OSGi Bundle Requirement");
     }
 
-
     public String getSymbolicName()
     {
         return symbolicName;
     }
 
-
-    public void setSymbolicName( String symbolicName )
+    public void setSymbolicName(String symbolicName)
     {
         this.symbolicName = symbolicName == null ? null : symbolicName.intern();
     }
 
-
     public VersionRange getVersions()
     {
         return versions;
     }
 
-
-    public void setVersions( VersionRange versions )
+    public void setVersions(VersionRange versions)
     {
         this.versions = versions == null ? VersionRange.ANY_VERSION : versions;
     }
 
-
     public boolean isOptional()
     {
         return optional;
     }
 
-
-    public void setOptional( boolean optional )
+    public void setOptional(boolean optional)
     {
         this.optional = optional;
     }
 
-
     @Override
     public String toString()
     {
-        return "RequiredBundle[" + symbolicName + ":" + versions + ":" + ( optional ? "optional" : "mandatory" ) + "]";
+        return "RequiredBundle[" + symbolicName + ":" + versions + ":"
+            + (optional ? "optional" : "mandatory") + "]";
     }
 
-
     @Override
-    public boolean equals( Object obj )
+    public boolean equals(Object obj)
     {
-        if ( this == obj )
+        if (this == obj)
             return true;
-        if ( obj == null )
+        if (obj == null)
             return false;
 
-        if ( obj instanceof RequiredBundle )
+        if (obj instanceof RequiredBundle)
         {
-            RequiredBundle rb = ( RequiredBundle ) obj;
-            return symbolicName.equals( rb.symbolicName ) && versions.equals( rb.versions ) && optional == rb.optional;
+            RequiredBundle rb = (RequiredBundle) obj;
+            return symbolicName.equals(rb.symbolicName) && versions.equals(rb.versions)
+                && optional == rb.optional;
         }
         else
         {
@@ -104,13 +95,12 @@
         }
     }
 
-
     @Override
     public int hashCode()
     {
         int hc = symbolicName.hashCode() * versions.hashCode();
 
-        if ( optional )
+        if (optional)
         {
             hc *= -1;
         }
@@ -118,13 +108,13 @@
         return hc;
     }
 
-
-    public boolean accepts( ICapabilityModelElement provider )
+    public boolean accepts(ICapabilityModelElement provider)
     {
-        if ( provider instanceof IBundleCapability )
+        if (provider instanceof IBundleCapability)
         {
-            IBundleCapability bndl = ( IBundleCapability ) provider;
-            return symbolicName.equals( bndl.getSymbolicName() ) && versions.contains( bndl.getVersion() );
+            IBundleCapability bndl = (IBundleCapability) provider;
+            return symbolicName.equals(bndl.getSymbolicName())
+                && versions.contains(bndl.getVersion());
         }
         else
         {
@@ -132,25 +122,23 @@
         }
     }
 
-
-    public int compareTo( IRequiredBundle o )
+    public int compareTo(IRequiredBundle o)
     {
-        int i = symbolicName.compareTo( o.getSymbolicName() );
+        int i = symbolicName.compareTo(o.getSymbolicName());
 
-        if ( i == 0 )
+        if (i == 0)
         {
-            i = compareVersion( o.getVersions() );
+            i = compareVersion(o.getVersions());
         }
 
         return i;
     }
 
-
-    private int compareVersion( VersionRange range )
+    private int compareVersion(VersionRange range)
     {
-        if ( versions == null )
+        if (versions == null)
         {
-            if ( range == null )
+            if (range == null)
             {
                 return 0;
             }
@@ -161,13 +149,13 @@
         }
         else
         {
-            if ( range == null )
+            if (range == null)
             {
                 return -1;
             }
             else
             {
-                return versions.getCeiling().compareTo( range.getCeiling() );
+                return versions.getCeiling().compareTo(range.getCeiling());
             }
         }
     }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicenseManager.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicenseManager.java
index cd615d4..ecc57a9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicenseManager.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicenseManager.java
@@ -19,24 +19,18 @@
 
 package org.apache.felix.sigil.common.core.licence;
 
-
 import java.util.Set;
 import java.util.regex.Pattern;
 
-
 public interface ILicenseManager
 {
-    void addLicense( String name, Pattern pattern );
+    void addLicense(String name, Pattern pattern);
 
-
-    void removeLicense( String name );
-
+    void removeLicense(String name);
 
     Set<String> getLicenseNames();
 
-
-    Pattern getLicensePattern( String name );
-
+    Pattern getLicensePattern(String name);
 
     ILicensePolicy getDefaultPolicy();
     //ILicensePolicy getPolicy(ISigilProjectModel project);
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicensePolicy.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicensePolicy.java
index ba2d931..eefef3c 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicensePolicy.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicensePolicy.java
@@ -19,21 +19,16 @@
 
 package org.apache.felix.sigil.common.core.licence;
 
-
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 import org.eclipse.core.runtime.IProgressMonitor;
 
-
 public interface ILicensePolicy
 {
-    void addAllowed( String licenseName );
+    void addAllowed(String licenseName);
 
+    void removeAllowed(String licenseName);
 
-    void removeAllowed( String licenseName );
+    boolean accept(ISigilBundle bundle);
 
-
-    boolean accept( ISigilBundle bundle );
-
-
-    void save( IProgressMonitor monitor );
+    void save(IProgressMonitor monitor);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java
index b8452ca..e75d258 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.repository;
 
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -55,7 +54,6 @@
 import org.eclipse.core.runtime.SubMonitor;
 import org.osgi.framework.Version;
 
-
 public class BundleResolver implements IBundleResolver
 {
 
@@ -63,36 +61,33 @@
     {
         private IModelElement requirement;
 
-
-        public BundleOrderComparator( IModelElement requirement )
+        public BundleOrderComparator(IModelElement requirement)
         {
             this.requirement = requirement;
         }
 
-
-        public int compare( ISigilBundle o1, ISigilBundle o2 )
+        public int compare(ISigilBundle o1, ISigilBundle o2)
         {
-            int c = compareVersions( o1, o2 );
+            int c = compareVersions(o1, o2);
 
-            if ( c == 0 )
+            if (c == 0)
             {
-                c = compareImports( o1, o2 );
+                c = compareImports(o1, o2);
             }
 
             return c;
         }
 
-
-        private int compareImports( ISigilBundle o1, ISigilBundle o2 )
+        private int compareImports(ISigilBundle o1, ISigilBundle o2)
         {
             int c1 = o1.getBundleInfo().getImports().size();
             int c2 = o2.getBundleInfo().getImports().size();
 
-            if ( c1 < c2 )
+            if (c1 < c2)
             {
                 return -1;
             }
-            else if ( c2 > c1 )
+            else if (c2 > c1)
             {
                 return 1;
             }
@@ -102,25 +97,24 @@
             }
         }
 
-
-        private int compareVersions( ISigilBundle o1, ISigilBundle o2 )
+        private int compareVersions(ISigilBundle o1, ISigilBundle o2)
         {
             Version v1 = null;
             Version v2 = null;
-            if ( requirement instanceof IPackageImport )
+            if (requirement instanceof IPackageImport)
             {
-                v1 = findExportVersion( ( IPackageImport ) requirement, o1 );
-                v2 = findExportVersion( ( IPackageImport ) requirement, o2 );
+                v1 = findExportVersion((IPackageImport) requirement, o1);
+                v2 = findExportVersion((IPackageImport) requirement, o2);
             }
-            else if ( requirement instanceof IRequiredBundle )
+            else if (requirement instanceof IRequiredBundle)
             {
                 v1 = o1.getBundleInfo().getVersion();
                 v2 = o1.getBundleInfo().getVersion();
             }
 
-            if ( v1 == null )
+            if (v1 == null)
             {
-                if ( v2 == null )
+                if (v2 == null)
                 {
                     return 0;
                 }
@@ -131,23 +125,22 @@
             }
             else
             {
-                if ( v2 == null )
+                if (v2 == null)
                 {
                     return -1;
                 }
                 else
                 {
-                    return v2.compareTo( v1 );
+                    return v2.compareTo(v1);
                 }
             }
         }
 
-
-        private Version findExportVersion( IPackageImport pi, ISigilBundle o1 )
+        private Version findExportVersion(IPackageImport pi, ISigilBundle o1)
         {
-            for ( IPackageExport pe : o1.getBundleInfo().getExports() )
+            for (IPackageExport pe : o1.getBundleInfo().getExports())
             {
-                if ( pi.getPackageName().equals( pi.getPackageName() ) )
+                if (pi.getPackageName().equals(pi.getPackageName()))
                 {
                     return pe.getVersion();
                 }
@@ -168,72 +161,64 @@
         private final Set<IModelElement> parsed = new HashSet<IModelElement>();
         private final LinkedList<IModelElement> requirements = new LinkedList<IModelElement>();
 
-
-        public ResolutionContext( IModelElement root, ResolutionConfig config, IResolutionMonitor monitor )
+        public ResolutionContext(IModelElement root, ResolutionConfig config, IResolutionMonitor monitor)
         {
             this.root = root;
             this.config = config;
             this.monitor = monitor;
         }
 
-
-        public void enterModelElement( IModelElement element )
+        public void enterModelElement(IModelElement element)
         {
-            parsed.add( element );
+            parsed.add(element);
         }
 
-
-        public void exitModelElement( IModelElement element )
+        public void exitModelElement(IModelElement element)
         {
-            parsed.remove( element );
+            parsed.remove(element);
         }
 
-
-        public boolean isNewModelElement( IModelElement element )
+        public boolean isNewModelElement(IModelElement element)
         {
-            return !parsed.contains( element );
+            return !parsed.contains(element);
         }
 
-
         public boolean isValid()
         {
             return resolution.isSuccess();
         }
 
-
-        public void setValid( boolean valid )
+        public void setValid(boolean valid)
         {
-            resolution.setSuccess( valid );
+            resolution.setSuccess(valid);
         }
 
-
         public ResolutionException newResolutionException()
         {
-            return new ResolutionException( root, requirements.toArray( new IModelElement[requirements.size()] ) );
+            return new ResolutionException(root,
+                requirements.toArray(new IModelElement[requirements.size()]));
         }
 
-
-        public void startRequirement( IRequirementModelElement element )
+        public void startRequirement(IRequirementModelElement element)
         {
-            requirements.add( element );
-            monitor.startResolution( element );
+            requirements.add(element);
+            monitor.startResolution(element);
         }
 
-
-        public void endRequirement( IRequirementModelElement element )
+        public void endRequirement(IRequirementModelElement element)
         {
-            ISigilBundle provider = resolution.getProvider( element );
+            ISigilBundle provider = resolution.getProvider(element);
 
-            setValid( provider != null || element.isOptional() || config.isIgnoreErrors() );
+            setValid(provider != null || element.isOptional() || config.isIgnoreErrors());
 
-            if ( isValid() )
+            if (isValid())
             {
                 // only clear stack if valid
                 // else use it as an aid to trace errors
-                requirements.remove( element );
+                requirements.remove(element);
             }
 
-            monitor.endResolution( element, provider );
+            monitor.endResolution(element, provider);
         }
     }
 
@@ -243,74 +228,66 @@
         private Map<IModelElement, ISigilBundle> providers = new HashMap<IModelElement, ISigilBundle>();
         private boolean success = true; // assume success
 
-
-        boolean addProvider( IModelElement element, ISigilBundle provider )
+        boolean addProvider(IModelElement element, ISigilBundle provider)
         {
-            providers.put( element, provider );
+            providers.put(element, provider);
 
-            List<IModelElement> requirements = providees.get( provider );
+            List<IModelElement> requirements = providees.get(provider);
 
             boolean isNewProvider = requirements == null;
 
-            if ( isNewProvider )
+            if (isNewProvider)
             {
                 requirements = new ArrayList<IModelElement>();
-                providees.put( provider, requirements );
+                providees.put(provider, requirements);
             }
 
-            requirements.add( element );
+            requirements.add(element);
 
             return isNewProvider;
         }
 
-
-        void removeProvider( IModelElement element, ISigilBundle provider )
+        void removeProvider(IModelElement element, ISigilBundle provider)
         {
-            providers.remove( element );
-            List<IModelElement> e = providees.get( provider );
-            e.remove( element );
-            if ( e.isEmpty() )
+            providers.remove(element);
+            List<IModelElement> e = providees.get(provider);
+            e.remove(element);
+            if (e.isEmpty())
             {
-                providees.remove( provider );
+                providees.remove(provider);
             }
         }
 
-
-        void setSuccess( boolean success )
+        void setSuccess(boolean success)
         {
             this.success = success;
         }
 
-
         public boolean isSuccess()
         {
             return success;
         }
 
-
-        public ISigilBundle getProvider( IModelElement requirement )
+        public ISigilBundle getProvider(IModelElement requirement)
         {
-            return providers.get( requirement );
+            return providers.get(requirement);
         }
 
-
         public Set<ISigilBundle> getBundles()
         {
             return providees.keySet();
         }
 
-
-        public List<IModelElement> getMatchedRequirements( ISigilBundle bundle )
+        public List<IModelElement> getMatchedRequirements(ISigilBundle bundle)
         {
-            return providees.get( bundle );
+            return providees.get(bundle);
         }
 
-
         public boolean isSynchronized()
         {
-            for ( ISigilBundle b : getBundles() )
+            for (ISigilBundle b : getBundles())
             {
-                if ( !b.isSynchronized() )
+                if (!b.isSynchronized())
                 {
                     return false;
                 }
@@ -319,26 +296,25 @@
             return true;
         }
 
-
-        public void synchronize( IProgressMonitor monitor )
+        public void synchronize(IProgressMonitor monitor)
         {
             Set<ISigilBundle> bundles = getBundles();
-            SubMonitor progress = SubMonitor.convert( monitor, bundles.size() );
+            SubMonitor progress = SubMonitor.convert(monitor, bundles.size());
 
-            for ( ISigilBundle b : bundles )
+            for (ISigilBundle b : bundles)
             {
-                if ( monitor.isCanceled() )
+                if (monitor.isCanceled())
                 {
                     break;
                 }
 
                 try
                 {
-                    b.synchronize( progress.newChild( 1 ) );
+                    b.synchronize(progress.newChild(1));
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
-                    BldCore.error( "Failed to synchronize " + b, e );
+                    BldCore.error("Failed to synchronize " + b, e);
                 }
             }
         }
@@ -346,18 +322,16 @@
 
     private static final IResolutionMonitor NULL_MONITOR = new IResolutionMonitor()
     {
-        public void endResolution( IModelElement requirement, ISigilBundle sigilBundle )
+        public void endResolution(IModelElement requirement, ISigilBundle sigilBundle)
         {
         }
 
-
         public boolean isCanceled()
         {
             return false;
         }
 
-
-        public void startResolution( IModelElement requirement )
+        public void startResolution(IModelElement requirement)
         {
         }
     };
@@ -366,20 +340,26 @@
     {
         public int compare(IRequirementModelElement o1, IRequirementModelElement o2)
         {
-            if ( o1 instanceof IPackageImport ) {
-                if (o2 instanceof IPackageImport ) {
+            if (o1 instanceof IPackageImport)
+            {
+                if (o2 instanceof IPackageImport)
+                {
                     return 0;
                 }
-                else {
+                else
+                {
                     return -1;
                 }
             }
-            else // assumes only alternative is IRequiredBundle
+            else
+            // assumes only alternative is IRequiredBundle
             {
-                if ( o2 instanceof IRequiredBundle) {
+                if (o2 instanceof IRequiredBundle)
+                {
                     return 0;
                 }
-                else {
+                else
+                {
                     return 1;
                 }
             }
@@ -388,25 +368,23 @@
 
     private IRepositoryManager repositoryManager;
 
-
-    public BundleResolver( IRepositoryManager repositoryManager )
+    public BundleResolver(IRepositoryManager repositoryManager)
     {
         this.repositoryManager = repositoryManager;
     }
 
-
-    public IResolution resolve( IModelElement element, ResolutionConfig config, IResolutionMonitor monitor )
-        throws ResolutionException
+    public IResolution resolve(IModelElement element, ResolutionConfig config,
+        IResolutionMonitor monitor) throws ResolutionException
     {
-        if ( monitor == null )
+        if (monitor == null)
         {
             monitor = NULL_MONITOR;
         }
-        ResolutionContext ctx = new ResolutionContext( element, config, monitor );
+        ResolutionContext ctx = new ResolutionContext(element, config, monitor);
 
-        resolveElement( element, ctx );
+        resolveElement(element, ctx);
 
-        if ( !ctx.isValid() )
+        if (!ctx.isValid())
         {
             throw ctx.newResolutionException();
         }
@@ -414,22 +392,25 @@
         return ctx.resolution;
     }
 
-    private void resolveElement( IModelElement element, ResolutionContext ctx ) throws ResolutionException
+    private void resolveElement(IModelElement element, ResolutionContext ctx)
+        throws ResolutionException
     {
-        if ( ctx.isValid() ) {
-            for (IRequirementModelElement req : findRequirements(element, ctx)) {
-                if ( ctx.monitor.isCanceled())
+        if (ctx.isValid())
+        {
+            for (IRequirementModelElement req : findRequirements(element, ctx))
+            {
+                if (ctx.monitor.isCanceled())
                     break;
                 resolveRequirement(req, ctx);
             }
         }
     }
-    
+
     private List<IRequirementModelElement> findRequirements(IModelElement element,
         final ResolutionContext ctx)
     {
         final LinkedList<IRequirementModelElement> reqs = new LinkedList<IRequirementModelElement>();
-        
+
         if (element instanceof IRequirementModelElement)
         {
             reqs.add((IRequirementModelElement) element);
@@ -445,102 +426,106 @@
                     {
                         reqs.add((IRequirementModelElement) element);
                     }
-                    else if ( element instanceof ILibrary ) {
-                        ILibrary lib = repositoryManager.resolveLibrary( ( ILibraryImport ) element );
-                        reqs.addAll( lib.getImports() );
+                    else if (element instanceof ILibrary)
+                    {
+                        ILibrary lib = repositoryManager.resolveLibrary((ILibraryImport) element);
+                        reqs.addAll(lib.getImports());
                     }
-                    
+
                     return !ctx.monitor.isCanceled();
                 }
             });
         }
 
-        if ( !ctx.monitor.isCanceled() ) {
+        if (!ctx.monitor.isCanceled())
+        {
             Collections.sort(reqs, REQUIREMENT_COMPARATOR);
-        }        
+        }
         return reqs;
     }
 
-    private void resolveRequirement( IRequirementModelElement requirement, ResolutionContext ctx ) throws ResolutionException
+    private void resolveRequirement(IRequirementModelElement requirement,
+        ResolutionContext ctx) throws ResolutionException
     {
-        if ( ctx.config.isOptional() || !requirement.isOptional() )
+        if (ctx.config.isOptional() || !requirement.isOptional())
         {
-            ctx.startRequirement( requirement );
+            ctx.startRequirement(requirement);
 
             try
             {
-                if ( !findInContext( requirement, ctx ) ) 
+                if (!findInContext(requirement, ctx))
                 {
-                    findInRepositories( requirement, ctx );
+                    findInRepositories(requirement, ctx);
                 }
             }
             finally
             {
-                ctx.endRequirement( requirement );
+                ctx.endRequirement(requirement);
             }
         }
     }
 
-
     private boolean findInContext(final IRequirementModelElement requirement,
         final ResolutionContext ctx)
     {
-        for ( final ISigilBundle b : ctx.resolution.providees.keySet() ) 
+        for (final ISigilBundle b : ctx.resolution.providees.keySet())
         {
-            b.visit( new IModelWalker() 
+            b.visit(new IModelWalker()
             {
                 public boolean visit(IModelElement element)
                 {
-                    if ( element instanceof ICapabilityModelElement ) {
-                        if ( requirement.accepts((ICapabilityModelElement) element) ) {
-                            ctx.resolution.addProvider( requirement, b );
+                    if (element instanceof ICapabilityModelElement)
+                    {
+                        if (requirement.accepts((ICapabilityModelElement) element))
+                        {
+                            ctx.resolution.addProvider(requirement, b);
                             return false;
                         }
                     }
                     return !ctx.monitor.isCanceled();
                 }
-                
+
             });
         }
-        
+
         return ctx.resolution.getProvider(requirement) != null;
     }
 
-
     private void findInRepositories(IRequirementModelElement requirement,
         ResolutionContext ctx) throws ResolutionException
     {
         int[] priorities = repositoryManager.getPriorityLevels();
 
-        outer: for ( int i = 0; i < priorities.length; i++ )
+        outer: for (int i = 0; i < priorities.length; i++)
         {
-            List<ISigilBundle> providers = findProvidersAtPriority( priorities[i], requirement, ctx );
+            List<ISigilBundle> providers = findProvidersAtPriority(priorities[i],
+                requirement, ctx);
 
-            if ( !providers.isEmpty() && !ctx.monitor.isCanceled() )
+            if (!providers.isEmpty() && !ctx.monitor.isCanceled())
             {
-                if ( providers.size() > 1 )
+                if (providers.size() > 1)
                 {
-                    Collections.sort( providers, new BundleOrderComparator( requirement ) );
+                    Collections.sort(providers, new BundleOrderComparator(requirement));
                 }
 
-                for ( ISigilBundle provider : providers )
+                for (ISigilBundle provider : providers)
                 {
                     // reset validity - if there's another provider it can still be solved
-                    ctx.setValid( true );
-                    if ( ctx.resolution.addProvider( requirement, provider ) )
+                    ctx.setValid(true);
+                    if (ctx.resolution.addProvider(requirement, provider))
                     {
-                        if ( ctx.config.isDependents() )
+                        if (ctx.config.isDependents())
                         {
-                            resolveElement( provider, ctx );
+                            resolveElement(provider, ctx);
                         }
 
-                        if ( ctx.isValid() )
+                        if (ctx.isValid())
                         {
                             break outer;
                         }
                         else
                         {
-                            ctx.resolution.removeProvider( requirement, provider );
+                            ctx.resolution.removeProvider(requirement, provider);
                         }
                     }
                     else
@@ -552,45 +537,44 @@
         }
     }
 
-
-    private List<ISigilBundle> findProvidersAtPriority( int i, IRequirementModelElement requirement, ResolutionContext ctx )
+    private List<ISigilBundle> findProvidersAtPriority(int i,
+        IRequirementModelElement requirement, ResolutionContext ctx)
         throws ResolutionException
     {
         ArrayList<ISigilBundle> providers = new ArrayList<ISigilBundle>();
 
-        for ( IBundleRepository rep : repositoryManager.getRepositories( i ) )
+        for (IBundleRepository rep : repositoryManager.getRepositories(i))
         {
-            if ( ctx.monitor.isCanceled() )
+            if (ctx.monitor.isCanceled())
             {
                 break;
             }
-            providers.addAll( findProviders( requirement, ctx.config, rep ) );
+            providers.addAll(findProviders(requirement, ctx.config, rep));
         }
 
         return providers;
     }
 
-
-    private Collection<ISigilBundle> findProviders( IRequirementModelElement requirement, ResolutionConfig config,
-        IBundleRepository rep ) throws ResolutionException
+    private Collection<ISigilBundle> findProviders(IRequirementModelElement requirement,
+        ResolutionConfig config, IBundleRepository rep) throws ResolutionException
     {
         ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
 
-        if ( requirement instanceof IPackageImport )
+        if (requirement instanceof IPackageImport)
         {
-            IPackageImport pi = ( IPackageImport ) requirement;
-            found.addAll( rep.findAllProviders( pi, config.getOptions() ) );
+            IPackageImport pi = (IPackageImport) requirement;
+            found.addAll(rep.findAllProviders(pi, config.getOptions()));
         }
-        else if ( requirement instanceof IRequiredBundle )
+        else if (requirement instanceof IRequiredBundle)
         {
-            IRequiredBundle rb = ( IRequiredBundle ) requirement;
-            found.addAll( rep.findAllProviders( rb, config.getOptions() ) );
+            IRequiredBundle rb = (IRequiredBundle) requirement;
+            found.addAll(rep.findAllProviders(rb, config.getOptions()));
         }
         else
         {
             // shouldn't get here - developer error if do
             // use isRequirement before getting anywhere near this logic...
-            throw new IllegalStateException( "Invalid requirement type " + requirement );
+            throw new IllegalStateException("Invalid requirement type " + requirement);
         }
 
         return found;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java
index 05b712e..4eaaea1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.repository;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.util.List;
@@ -33,61 +32,61 @@
 import org.apache.felix.sigil.common.model.osgi.IBundleModelElement;
 import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
 
-
 public class DirectoryHelper
 {
-    public static void scanBundles( AbstractBundleRepository repository, List<ISigilBundle> bundles, File dir,
-        File source, boolean recursive )
+    public static void scanBundles(AbstractBundleRepository repository,
+        List<ISigilBundle> bundles, File dir, File source, boolean recursive)
     {
-        if ( dir.exists() )
+        if (dir.exists())
         {
-            for ( File f : dir.listFiles() )
+            for (File f : dir.listFiles())
             {
-                if ( f.isDirectory() )
+                if (f.isDirectory())
                 {
-                    if ( recursive )
+                    if (recursive)
                     {
-                        scanBundles( repository, bundles, f, source, recursive );
+                        scanBundles(repository, bundles, f, source, recursive);
                     }
                 }
-                else if ( f.isFile() && f.getName().endsWith( ".jar" ) )
+                else if (f.isFile() && f.getName().endsWith(".jar"))
                 {
                     JarFile jar = null;
                     try
                     {
-                        jar = new JarFile( f, false );
-                        ISigilBundle bundle = buildBundle( repository, jar.getManifest(), f );
-                        if ( bundle != null )
+                        jar = new JarFile(f, false);
+                        ISigilBundle bundle = buildBundle(repository, jar.getManifest(),
+                            f);
+                        if (bundle != null)
                         {
-                            bundle.setSourcePathLocation( source );
+                            bundle.setSourcePathLocation(source);
                             // TODO shouldn't be hard coded
-                            bundle.setSourceRootPath( "src" );
-                            bundles.add( bundle );
+                            bundle.setSourceRootPath("src");
+                            bundles.add(bundle);
                         }
                     }
-                    catch ( IOException e )
+                    catch (IOException e)
                     {
-                        BldCore.error( "Failed to read jar file " + f, e );
+                        BldCore.error("Failed to read jar file " + f, e);
                     }
-                    catch ( ModelElementFactoryException e )
+                    catch (ModelElementFactoryException e)
                     {
-                        BldCore.error( "Failed to build bundle " + f, e );
+                        BldCore.error("Failed to build bundle " + f, e);
                     }
-                    catch ( RuntimeException e )
+                    catch (RuntimeException e)
                     {
-                        BldCore.error( "Failed to build bundle " + f, e );
+                        BldCore.error("Failed to build bundle " + f, e);
                     }
                     finally
                     {
-                        if ( jar != null )
+                        if (jar != null)
                         {
                             try
                             {
                                 jar.close();
                             }
-                            catch ( IOException e )
+                            catch (IOException e)
                             {
-                                BldCore.error( "Failed to close jar file", e );
+                                BldCore.error("Failed to close jar file", e);
                             }
                         }
                     }
@@ -96,18 +95,18 @@
         }
     }
 
-
-    private static ISigilBundle buildBundle( AbstractBundleRepository repository, Manifest manifest, File f )
+    private static ISigilBundle buildBundle(AbstractBundleRepository repository,
+        Manifest manifest, File f)
     {
-        IBundleModelElement info = repository.buildBundleModelElement( manifest );
+        IBundleModelElement info = repository.buildBundleModelElement(manifest);
 
         ISigilBundle bundle = null;
 
-        if ( info != null )
+        if (info != null)
         {
-            bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
-            bundle.addChild( info );
-            bundle.setLocation( f );
+            bundle = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
+            bundle.addChild(info);
+            bundle.setLocation(f);
         }
 
         return bundle;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java
index ef46fab..b20c32c 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.repository;
 
-
 import java.io.File;
 import java.util.ArrayList;
 
@@ -27,7 +26,6 @@
 import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
 import org.apache.felix.sigil.common.repository.IRepositoryVisitor;
 
-
 public class FileSystemRepository extends AbstractBundleRepository
 {
 
@@ -35,40 +33,37 @@
     private File dir;
     private boolean recurse;
 
-
-    public FileSystemRepository( String id, File dir, boolean recurse )
+    public FileSystemRepository(String id, File dir, boolean recurse)
     {
-        super( id );
+        super(id);
         this.dir = dir;
         this.recurse = recurse;
     }
 
-
     @Override
-    public void accept( IRepositoryVisitor visitor, int options )
+    public void accept(IRepositoryVisitor visitor, int options)
     {
-        synchronized ( this )
+        synchronized (this)
         {
-            if ( bundles == null )
+            if (bundles == null)
             {
                 bundles = new ArrayList<ISigilBundle>();
-                DirectoryHelper.scanBundles( this, bundles, dir, null, recurse );
+                DirectoryHelper.scanBundles(this, bundles, dir, null, recurse);
             }
         }
 
-        for ( ISigilBundle b : bundles )
+        for (ISigilBundle b : bundles)
         {
-            if ( !visitor.visit( b ) )
+            if (!visitor.visit(b))
             {
                 break;
             }
         }
     }
 
-
     public void refresh()
     {
-        synchronized ( this )
+        synchronized (this)
         {
             bundles = null;
         }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java
index d1c9227..0926558 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.repository;
 
-
 import java.io.File;
 import java.util.Properties;
 
@@ -27,20 +26,20 @@
 import org.apache.felix.sigil.common.repository.IRepositoryProvider;
 import org.apache.felix.sigil.common.repository.RepositoryException;
 
-
 public class FileSystemRepositoryProvider implements IRepositoryProvider
 {
 
-    public IBundleRepository createRepository( String id, Properties preferences ) throws RepositoryException
+    public IBundleRepository createRepository(String id, Properties preferences)
+        throws RepositoryException
     {
-        String dirStr = preferences.getProperty( "dir" );
-        File dir = new File( dirStr );
-        if ( !dir.isDirectory() )
+        String dirStr = preferences.getProperty("dir");
+        File dir = new File(dirStr);
+        if (!dir.isDirectory())
         {
-            throw new RepositoryException( "directory '" + dir + "' does not exist." );
+            throw new RepositoryException("directory '" + dir + "' does not exist.");
         }
-        boolean recurse = Boolean.valueOf( preferences.getProperty( "recurse" ) );
-        return new FileSystemRepository( id, dir, recurse );
+        boolean recurse = Boolean.valueOf(preferences.getProperty("recurse"));
+        return new FileSystemRepository(id, dir, recurse);
     }
 
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java
index 2cb307a..e1db339 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java
@@ -19,72 +19,61 @@
 
 package org.apache.felix.sigil.common.core.repository;
 
-
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.apache.felix.sigil.common.repository.IResolutionMonitor;
 
-
 public class ProgressWrapper implements IProgressMonitor
 {
 
     private IResolutionMonitor monitor;
 
-
-    public ProgressWrapper( IResolutionMonitor monitor )
+    public ProgressWrapper(IResolutionMonitor monitor)
     {
         this.monitor = monitor;
     }
 
-
     public boolean isCanceled()
     {
         return monitor.isCanceled();
     }
 
-
-    public void beginTask( String name, int totalWork )
+    public void beginTask(String name, int totalWork)
     {
         // TODO Auto-generated method stub
 
     }
 
-
     public void done()
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    public void internalWorked( double work )
+    public void internalWorked(double work)
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    public void setCanceled( boolean value )
+    public void setCanceled(boolean value)
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    public void setTaskName( String name )
+    public void setTaskName(String name)
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    public void subTask( String name )
+    public void subTask(String name)
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    public void worked( int work )
+    public void worked(int work)
     {
         // TODO Auto-generated method stub
 
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java
index 00503f4..cfd0b77 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.repository;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.util.jar.JarFile;
@@ -33,87 +32,85 @@
 import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
 import org.apache.felix.sigil.common.repository.IRepositoryVisitor;
 
-
 public class SystemRepository extends AbstractBundleRepository
 {
 
     private final String packages;
     private final File frameworkPath;
 
-
-    public SystemRepository( String id, File frameworkPath, String packages )
+    public SystemRepository(String id, File frameworkPath, String packages)
     {
-        super( id );
+        super(id);
         this.frameworkPath = frameworkPath;
         this.packages = packages;
     }
 
     private static ISigilBundle systemBundle;
 
-
     @Override
-    public void accept( IRepositoryVisitor visitor, int options )
+    public void accept(IRepositoryVisitor visitor, int options)
     {
         ISigilBundle bundle = loadSystemBundle();
 
-        if ( bundle != null )
+        if (bundle != null)
         {
-            visitor.visit( bundle );
+            visitor.visit(bundle);
         }
     }
 
-
     private synchronized ISigilBundle loadSystemBundle()
     {
-        if ( systemBundle == null )
+        if (systemBundle == null)
         {
-            systemBundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
+            systemBundle = ModelElementFactory.getInstance().newModelElement(
+                ISigilBundle.class);
 
             JarFile jar = null;
 
             try
             {
                 final IBundleModelElement info;
-                if ( frameworkPath != null )
+                if (frameworkPath != null)
                 {
-                    systemBundle.setLocation( frameworkPath );
+                    systemBundle.setLocation(frameworkPath);
                     jar = new JarFile(frameworkPath);
-                    info = buildBundleModelElement( jar.getManifest() );
+                    info = buildBundleModelElement(jar.getManifest());
                 }
                 else
                 {
-                    info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
+                    info = ModelElementFactory.getInstance().newModelElement(
+                        IBundleModelElement.class);
                 }
 
                 info.setSymbolicName("system bundle");
                 info.setName("Sigil system bundle");
-                
-                applyProfile( info );
-                systemBundle.addChild( info );
+
+                applyProfile(info);
+                systemBundle.addChild(info);
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                BldCore.error( "Failed to read jar file " + frameworkPath, e );
+                BldCore.error("Failed to read jar file " + frameworkPath, e);
             }
-            catch ( ModelElementFactoryException e )
+            catch (ModelElementFactoryException e)
             {
-                BldCore.error( "Failed to build bundle " + frameworkPath, e );
+                BldCore.error("Failed to build bundle " + frameworkPath, e);
             }
-            catch ( RuntimeException e )
+            catch (RuntimeException e)
             {
-                BldCore.error( "Failed to build bundle " + frameworkPath, e );
+                BldCore.error("Failed to build bundle " + frameworkPath, e);
             }
             finally
             {
-                if ( jar != null )
+                if (jar != null)
                 {
                     try
                     {
                         jar.close();
                     }
-                    catch ( IOException e )
+                    catch (IOException e)
                     {
-                        BldCore.error( "Failed to close jar file", e );
+                        BldCore.error("Failed to close jar file", e);
                     }
                 }
             }
@@ -122,21 +119,20 @@
         return systemBundle;
     }
 
-
-    private void applyProfile( IBundleModelElement info )
+    private void applyProfile(IBundleModelElement info)
     {
-        if ( packages != null )
+        if (packages != null)
         {
-            for ( String name : packages.split( ",\\s*" ) )
+            for (String name : packages.split(",\\s*"))
             {
-                IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
-                pe.setPackageName( name );
-                info.addExport( pe );
+                IPackageExport pe = ModelElementFactory.getInstance().newModelElement(
+                    IPackageExport.class);
+                pe.setPackageName(name);
+                info.addExport(pe);
             }
         }
     }
 
-
     public synchronized void refresh()
     {
         systemBundle = null;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java
index 47a72f3..0d19199 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.core.repository;
 
-
 import java.io.File;
 import java.io.IOException;
 
@@ -33,44 +32,46 @@
 public class SystemRepositoryProvider implements IRepositoryProvider
 {
 
-    public IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException
+    public IBundleRepository createRepository(String id, Properties properties)
+        throws RepositoryException
     {
-        String fw = properties.getProperty( "framework" );
-        File frameworkPath = fw == null ? null : new File( fw );
-        String extraPkgs = properties.getProperty( "packages" );
-        String profile = properties.getProperty( "profile" );
-        
+        String fw = properties.getProperty("framework");
+        File frameworkPath = fw == null ? null : new File(fw);
+        String extraPkgs = properties.getProperty("packages");
+        String profile = properties.getProperty("profile");
+
         try
         {
-            Properties p = readProfile( profile );
-            String pkgs = p.getProperty( "org.osgi.framework.system.packages" ) + "," + extraPkgs;
-            return new SystemRepository( id, frameworkPath, pkgs );
+            Properties p = readProfile(profile);
+            String pkgs = p.getProperty("org.osgi.framework.system.packages") + ","
+                + extraPkgs;
+            return new SystemRepository(id, frameworkPath, pkgs);
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
-            throw new RepositoryException( "Failed to load profile", e );
+            throw new RepositoryException("Failed to load profile", e);
         }
     }
 
-
-    public static Properties readProfile( String name ) throws IOException
+    public static Properties readProfile(String name) throws IOException
     {
-        if ( name == null )
+        if (name == null)
         {
-            String version = System.getProperty( "java.specification.version" );
-            String[] split = version.split( "\\." );
-            String prefix = ( "6".compareTo( split[1] ) <= 0 ) ? "JavaSE-" : "J2SE-";
+            String version = System.getProperty("java.specification.version");
+            String[] split = version.split("\\.");
+            String prefix = ("6".compareTo(split[1]) <= 0) ? "JavaSE-" : "J2SE-";
             name = prefix + version;
         }
 
         String profilePath = "profiles/" + name + ".profile";
-        InputStream in = SystemRepositoryProvider.class.getClassLoader().getResourceAsStream( profilePath );
+        InputStream in = SystemRepositoryProvider.class.getClassLoader().getResourceAsStream(
+            profilePath);
 
-        if ( in == null )
-            throw new IOException( "No such profile: " + profilePath );
+        if (in == null)
+            throw new IOException("No such profile: " + profilePath);
 
         Properties p = new Properties();
-        p.load( in );
+        p.load(in);
 
         return p;
     }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java
index d08388c..750c426 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java
@@ -18,65 +18,66 @@
 
 public class ManifestUtil
 {
-    public static IBundleModelElement buildBundleModelElement( Manifest mf )
+    public static IBundleModelElement buildBundleModelElement(Manifest mf)
     {
         IBundleModelElement info = null;
 
-        if ( mf != null )
+        if (mf != null)
         {
             Attributes attrs = mf.getMainAttributes();
-            String name = attrs.getValue( "Bundle-SymbolicName" );
-            if ( name == null )
+            String name = attrs.getValue("Bundle-SymbolicName");
+            if (name == null)
             {
                 // framework.jar doesn't have Bundle-SymbolicName!
-                name = attrs.getValue( "Bundle-Name" );
+                name = attrs.getValue("Bundle-Name");
             }
 
-            if ( name != null )
+            if (name != null)
             {
                 try
                 {
-                    info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
-                    info.setSymbolicName( name.split( ";" )[0] );
-                    info.setVersion( VersionTable.getVersion( attrs.getValue( "Bundle-Version" ) ) );
-                    info.setName( attrs.getValue( "Bundle-Name" ) );
-                    info.setDescription( attrs.getValue( "Bundle-Description" ) );
-                    info.setVendor( attrs.getValue( "Bundle-Vendor" ) );
+                    info = ModelElementFactory.getInstance().newModelElement(
+                        IBundleModelElement.class);
+                    info.setSymbolicName(name.split(";")[0]);
+                    info.setVersion(VersionTable.getVersion(attrs.getValue("Bundle-Version")));
+                    info.setName(attrs.getValue("Bundle-Name"));
+                    info.setDescription(attrs.getValue("Bundle-Description"));
+                    info.setVendor(attrs.getValue("Bundle-Vendor"));
 
-                    String str = attrs.getValue( "Import-Package" );
-                    if ( str != null )
+                    String str = attrs.getValue("Import-Package");
+                    if (str != null)
                     {
-                        addImports( info, str );
+                        addImports(info, str);
                     }
 
-                    str = attrs.getValue( "Export-Package" );
-                    if ( str != null )
+                    str = attrs.getValue("Export-Package");
+                    if (str != null)
                     {
-                        addExports( info, str );
+                        addExports(info, str);
                     }
 
-                    str = attrs.getValue( "Require-Bundle" );
-                    if ( str != null )
+                    str = attrs.getValue("Require-Bundle");
+                    if (str != null)
                     {
-                        addRequires( info, str );
+                        addRequires(info, str);
                     }
 
-                    str = attrs.getValue( "Bundle-Classpath" );
+                    str = attrs.getValue("Bundle-Classpath");
 
-                    if ( str != null )
+                    if (str != null)
                     {
-                        addClasspath( info, str );
+                        addClasspath(info, str);
                     }
 
-                    str = attrs.getValue( "Fragment-Host" );
-                    if ( str != null )
+                    str = attrs.getValue("Fragment-Host");
+                    if (str != null)
                     {
-                        addHost( info, str );
+                        addHost(info, str);
                     }
                 }
-                catch ( RuntimeException e )
+                catch (RuntimeException e)
                 {
-                    BldCore.error( "Failed to read info from bundle " + name, e );
+                    BldCore.error("Failed to read info from bundle " + name, e);
                     // clear elements as clearly got garbage
                     info = null;
                 }
@@ -85,151 +86,152 @@
 
         return info;
     }
-    private static void addClasspath( IBundleModelElement info, String cpStr )
+
+    private static void addClasspath(IBundleModelElement info, String cpStr)
     {
-        for ( String cp : cpStr.split( "\\s*,\\s*" ) )
+        for (String cp : cpStr.split("\\s*,\\s*"))
         {
-            info.addClasspath( cp );
+            info.addClasspath(cp);
         }
     }
 
-
-    private static void addExports( IBundleModelElement info, String exportStr ) throws ModelElementFactoryException
+    private static void addExports(IBundleModelElement info, String exportStr)
+        throws ModelElementFactoryException
     {
-        for ( String exp : QuoteUtil.split( exportStr ) )
+        for (String exp : QuoteUtil.split(exportStr))
         {
             try
             {
-                String[] parts = exp.split( ";" );
-                IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
-                pe.setPackageName( parts[0].trim() );
+                String[] parts = exp.split(";");
+                IPackageExport pe = ModelElementFactory.getInstance().newModelElement(
+                    IPackageExport.class);
+                pe.setPackageName(parts[0].trim());
 
-                if ( parts.length > 1 )
+                if (parts.length > 1)
                 {
-                    for ( int i = 1; i < parts.length; i++ )
+                    for (int i = 1; i < parts.length; i++)
                     {
                         String check = parts[i];
-                        if ( check.toLowerCase().startsWith( "version=" ) )
+                        if (check.toLowerCase().startsWith("version="))
                         {
-                            pe.setVersion( parseVersion( check.substring( "version=".length() ) ) );
+                            pe.setVersion(parseVersion(check.substring("version=".length())));
                         }
-                        else if ( check.toLowerCase().startsWith( "specification-version=" ) )
+                        else if (check.toLowerCase().startsWith("specification-version="))
                         {
-                            pe.setVersion( parseVersion( check.substring( "specification-version=".length() ) ) );
+                            pe.setVersion(parseVersion(check.substring("specification-version=".length())));
                         }
-                        else if ( check.toLowerCase().startsWith( "uses:=" ) )
+                        else if (check.toLowerCase().startsWith("uses:="))
                         {
-                            for ( String use : parseUses( check.substring( "uses:=".length() ) ) )
+                            for (String use : parseUses(check.substring("uses:=".length())))
                             {
-                                pe.addUse( use );
+                                pe.addUse(use);
                             }
                         }
                     }
                 }
-                info.addExport( pe );
+                info.addExport(pe);
             }
-            catch ( RuntimeException e )
+            catch (RuntimeException e)
             {
                 e.printStackTrace();
             }
         }
     }
 
-
-    private static Collection<String> parseUses( String uses )
+    private static Collection<String> parseUses(String uses)
     {
-        if ( uses.startsWith( "\"" ) )
+        if (uses.startsWith("\""))
         {
-            uses = uses.substring( 1, uses.length() - 2 );
+            uses = uses.substring(1, uses.length() - 2);
         }
 
-        return Arrays.asList( uses.split( "," ) );
+        return Arrays.asList(uses.split(","));
     }
 
-
-    private static Version parseVersion( String val )
+    private static Version parseVersion(String val)
     {
-        val = val.replaceAll( "\"", "" );
-        return VersionTable.getVersion( val );
+        val = val.replaceAll("\"", "");
+        return VersionTable.getVersion(val);
     }
 
-
-    private static void addImports( IBundleModelElement info, String importStr ) throws ModelElementFactoryException
+    private static void addImports(IBundleModelElement info, String importStr)
+        throws ModelElementFactoryException
     {
-        for ( String imp : QuoteUtil.split( importStr ) )
+        for (String imp : QuoteUtil.split(importStr))
         {
-            String[] parts = imp.split( ";" );
-            IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
-            pi.setPackageName( parts[0].trim() );
+            String[] parts = imp.split(";");
+            IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+                IPackageImport.class);
+            pi.setPackageName(parts[0].trim());
 
-            if ( parts.length > 1 )
+            if (parts.length > 1)
             {
-                for ( int i = 1; i < parts.length; i++ )
+                for (int i = 1; i < parts.length; i++)
                 {
                     String p = parts[i];
-                    if ( p.toLowerCase().startsWith( "version=" ) )
+                    if (p.toLowerCase().startsWith("version="))
                     {
-                        pi.setVersions( VersionRange.parseVersionRange( p.substring( "version=".length() ) ) );
+                        pi.setVersions(VersionRange.parseVersionRange(p.substring("version=".length())));
                     }
-                    else if ( p.toLowerCase().startsWith( "specification-version=" ) )
+                    else if (p.toLowerCase().startsWith("specification-version="))
                     {
-                        pi.setVersions( VersionRange
-                            .parseVersionRange( p.substring( "specification-version=".length() ) ) );
+                        pi.setVersions(VersionRange.parseVersionRange(p.substring("specification-version=".length())));
                     }
-                    else if ( p.toLowerCase().startsWith( "resolution:=" ) )
+                    else if (p.toLowerCase().startsWith("resolution:="))
                     {
-                        pi.setOptional( p.toLowerCase().substring( "resolution:=".length() ).equals( "optional" ) );
+                        pi.setOptional(p.toLowerCase().substring("resolution:=".length()).equals(
+                            "optional"));
                     }
                 }
             }
-            info.addImport( pi );
+            info.addImport(pi);
         }
     }
 
-
-    private static void addRequires( IBundleModelElement info, String reqStr ) throws ModelElementFactoryException
+    private static void addRequires(IBundleModelElement info, String reqStr)
+        throws ModelElementFactoryException
     {
-        for ( String imp : QuoteUtil.split( reqStr ) )
+        for (String imp : QuoteUtil.split(reqStr))
         {
-            String[] parts = imp.split( ";" );
-            IRequiredBundle req = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
-            req.setSymbolicName( parts[0] );
+            String[] parts = imp.split(";");
+            IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(
+                IRequiredBundle.class);
+            req.setSymbolicName(parts[0]);
 
-            if ( parts.length > 1 )
+            if (parts.length > 1)
             {
-                if ( parts[1].toLowerCase().startsWith( "version=" ) )
+                if (parts[1].toLowerCase().startsWith("version="))
                 {
-                    req.setVersions( VersionRange.parseVersionRange( parts[1].substring( "version=".length() ) ) );
+                    req.setVersions(VersionRange.parseVersionRange(parts[1].substring("version=".length())));
                 }
-                else if ( parts[1].toLowerCase().startsWith( "specification-version=" ) )
+                else if (parts[1].toLowerCase().startsWith("specification-version="))
                 {
-                    req.setVersions( VersionRange.parseVersionRange( parts[1].substring( "specification-version="
-                        .length() ) ) );
+                    req.setVersions(VersionRange.parseVersionRange(parts[1].substring("specification-version=".length())));
                 }
             }
-            info.addRequiredBundle( req );
+            info.addRequiredBundle(req);
         }
     }
 
-
     /**
      * @param info
      * @param str
      */
-    private static void addHost( IBundleModelElement info, String str )
+    private static void addHost(IBundleModelElement info, String str)
     {
-        String[] parts = str.split( ";" );
-        IRequiredBundle req = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
-        req.setSymbolicName( parts[0].trim() );
+        String[] parts = str.split(";");
+        IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(
+            IRequiredBundle.class);
+        req.setSymbolicName(parts[0].trim());
 
-        if ( parts.length > 1 )
+        if (parts.length > 1)
         {
             String part = parts[1].toLowerCase().trim();
-            if ( part.startsWith( "bundle-version=" ) )
+            if (part.startsWith("bundle-version="))
             {
-                req.setVersions( VersionRange.parseVersionRange( part.substring( "bundle-version=".length() ) ) );
+                req.setVersions(VersionRange.parseVersionRange(part.substring("bundle-version=".length())));
             }
         }
-        info.setFragmentHost( req );
+        info.setFragmentHost(req);
     }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java
index 609463e..dc88889 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java
@@ -19,43 +19,41 @@
 
 package org.apache.felix.sigil.common.core.util;
 
-
 import java.util.ArrayList;
 
-
 public class QuoteUtil
 {
-    public static String[] split( String str )
+    public static String[] split(String str)
     {
         ArrayList<String> split = new ArrayList<String>();
         boolean quote = false;
-        StringBuffer buf = new StringBuffer( str.length() );
+        StringBuffer buf = new StringBuffer(str.length());
 
-        for ( int i = 0; i < str.length(); i++ )
+        for (int i = 0; i < str.length(); i++)
         {
-            char c = str.charAt( i );
-            switch ( c )
+            char c = str.charAt(i);
+            switch (c)
             {
                 case '"':
                     quote = !quote;
                     break;
                 case ',':
-                    if ( !quote )
+                    if (!quote)
                     {
-                        split.add( buf.toString().trim() );
-                        buf.setLength( 0 );
+                        split.add(buf.toString().trim());
+                        buf.setLength(0);
                         break;
                     }
                     // else fall through on purpose
                 default:
-                    buf.append( c );
+                    buf.append(c);
             }
         }
 
-        if ( buf.length() > 0 )
+        if (buf.length() > 0)
         {
-            split.add( buf.toString().trim() );
+            split.add(buf.toString().trim());
         }
-        return split.toArray( new String[split.size()] );
+        return split.toArray(new String[split.size()]);
     }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java
index 8343eda..2bbf575 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java
@@ -19,37 +19,31 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-
 public abstract class AbstractCompoundModelElement extends AbstractModelElement implements ICompoundModelElement
 {
 
     private static final long serialVersionUID = 1L;
 
-
-    public AbstractCompoundModelElement( String description )
+    public AbstractCompoundModelElement(String description)
     {
-        super( description );
+        super(description);
     }
 
-
-    public boolean addChild( IModelElement child ) throws InvalidModelException
+    public boolean addChild(IModelElement child) throws InvalidModelException
     {
-        return support.addChild( child );
+        return support.addChild(child);
     }
 
-
-    public boolean removeChild( IModelElement child )
+    public boolean removeChild(IModelElement child)
     {
-        return support.removeChild( child );
+        return support.removeChild(child);
     }
 
-
     public IModelElement[] children()
     {
         return support.children();
@@ -57,85 +51,80 @@
 
     private static final ThreadLocal<Map<IModelWalker, Set<IModelElement>>> walkedLocal = new ThreadLocal<Map<IModelWalker, Set<IModelElement>>>();
 
-
-    public void visit( IModelWalker walker )
+    public void visit(IModelWalker walker)
     {
-        if ( walker.visit( this ) )
+        if (walker.visit(this))
         {
             Map<IModelWalker, Set<IModelElement>> walked = walkedLocal.get();
             boolean delete = false;
 
-            if ( walked == null )
+            if (walked == null)
             {
                 walked = new HashMap<IModelWalker, Set<IModelElement>>();
-                walkedLocal.set( walked );
+                walkedLocal.set(walked);
             }
 
-            Set<IModelElement> check = walked.get( walker );
+            Set<IModelElement> check = walked.get(walker);
 
-            if ( check == null )
+            if (check == null)
             {
                 delete = true;
                 check = new HashSet<IModelElement>();
             }
 
-            check.add( this );
+            check.add(this);
 
             try
             {
-                for ( IModelElement e : children() )
+                for (IModelElement e : children())
                 {
-                    if ( !check.contains( e ) && walker.visit( e ) )
+                    if (!check.contains(e) && walker.visit(e))
                     {
-                        check.add( e );
-                        if ( e instanceof ICompoundModelElement )
+                        check.add(e);
+                        if (e instanceof ICompoundModelElement)
                         {
-                            ICompoundModelElement c = ( ICompoundModelElement ) e;
-                            c.visit( walker );
+                            ICompoundModelElement c = (ICompoundModelElement) e;
+                            c.visit(walker);
                         }
                     }
                 }
             }
             finally
             {
-                if ( delete )
+                if (delete)
                 {
-                    walked.remove( walker );
+                    walked.remove(walker);
 
-                    if ( walked.isEmpty() )
+                    if (walked.isEmpty())
                     {
-                        walkedLocal.set( null );
+                        walkedLocal.set(null);
                     }
                 }
             }
         }
     }
 
-
     public Set<Class<? extends IModelElement>> getOptionalChildren()
     {
-        return support.getChildrenTypes( false );
+        return support.getChildrenTypes(false);
     }
 
-
     public Set<Class<? extends IModelElement>> getRequiredChildren()
     {
-        return support.getChildrenTypes( true );
+        return support.getChildrenTypes(true);
     }
 
-
-    public <T extends IModelElement> T[] childrenOfType( Class<T> type )
+    public <T extends IModelElement> T[] childrenOfType(Class<T> type)
     {
-        return support.childrenOfType( type );
+        return support.childrenOfType(type);
     }
 
-
     @Override
     public void checkValid() throws InvalidModelException
     {
         super.checkValid();
 
-        for ( IModelElement e : support.children() )
+        for (IModelElement e : support.children())
         {
             e.checkValid();
         }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java
index c2b7e72..ca2afe4 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java
@@ -19,14 +19,12 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 import java.io.Serializable;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
-
 public abstract class AbstractModelElement implements IModelElement
 {
 
@@ -41,65 +39,60 @@
 
     protected ModelElementSupport support;
 
-
-    public AbstractModelElement( String description )
+    public AbstractModelElement(String description)
     {
-        support = new ModelElementSupport( this );
+        support = new ModelElementSupport(this);
         this.description = description.intern();
     }
 
-
     public String getElementDescription()
     {
         return description;
     }
 
-
     public Map<Object, Object> getMeta()
     {
         return meta == null ? Collections.emptyMap() : Collections.unmodifiableMap(meta);
     }
 
-
-    public void setMeta( Map<Object, Object> meta )
+    public void setMeta(Map<Object, Object> meta)
     {
         this.meta = meta;
     }
 
-
     @Override
     public AbstractModelElement clone()
     {
         try
         {
-            AbstractModelElement clone = ( AbstractModelElement ) super.clone();
+            AbstractModelElement clone = (AbstractModelElement) super.clone();
 
-            if ( meta != null ) {
-                clone.meta = new HashMap<Object, Object>( meta );
+            if (meta != null)
+            {
+                clone.meta = new HashMap<Object, Object>(meta);
             }
-            
+
             clone.support = new ModelElementSupport(clone);
 
             return clone;
         }
-        catch ( CloneNotSupportedException e )
+        catch (CloneNotSupportedException e)
         {
             // can't happen but make compiler happy
-            throw new IllegalStateException( e );
+            throw new IllegalStateException(e);
         }
     }
 
-
     @SuppressWarnings("unchecked")
-    public <T extends IModelElement> T getAncestor( Class<T> type )
+    public <T extends IModelElement> T getAncestor(Class<T> type)
     {
         IModelElement parent = this.parent;
 
-        while ( parent != null )
+        while (parent != null)
         {
-            if ( type.isInstance( parent ) )
+            if (type.isInstance(parent))
             {
-                return ( T ) parent;
+                return (T) parent;
             }
             parent = parent.getParent();
         }
@@ -107,107 +100,101 @@
         return null;
     }
 
-
     public IModelElement getParent()
     {
         return parent;
     }
 
-
-    public void setParent( IModelElement parent )
+    public void setParent(IModelElement parent)
     {
-        if ( parent != null )
+        if (parent != null)
         {
-            if ( this.parent != null && this.parent != parent )
+            if (this.parent != null && this.parent != parent)
             {
-                throw new IllegalStateException( "Parent already installed" );
+                throw new IllegalStateException("Parent already installed");
             }
         }
 
         this.parent = parent;
     }
 
-
     public void checkValid() throws InvalidModelException
     {
-        for ( String req : getRequiredProperties() )
+        for (String req : getRequiredProperties())
         {
             try
             {
-                if ( getProperty( req ) == null )
+                if (getProperty(req) == null)
                 {
-                    throw new InvalidModelException( this, "Missing property " + req );
+                    throw new InvalidModelException(this, "Missing property " + req);
                 }
             }
-            catch ( NoSuchMethodException e )
+            catch (NoSuchMethodException e)
             {
-                throw new InvalidModelException( this, "No such property " + req );
+                throw new InvalidModelException(this, "No such property " + req);
             }
         }
     }
 
-
-    public Object getProperty( String name ) throws NoSuchMethodException
+    public Object getProperty(String name) throws NoSuchMethodException
     {
-        return support.getProperty( name );
+        return support.getProperty(name);
     }
 
-
-    public void setProperty( String name, Object value ) throws NoSuchMethodException
+    public void setProperty(String name, Object value) throws NoSuchMethodException
     {
-        support.setProperty( name, value );
+        support.setProperty(name, value);
     }
 
-
-    public void addProperty( String name, Object value ) throws NoSuchMethodException
+    public void addProperty(String name, Object value) throws NoSuchMethodException
     {
-        support.addProperty( name, value );
+        support.addProperty(name, value);
     }
 
-
-    public void removeProperty( String name, Object value ) throws NoSuchMethodException
+    public void removeProperty(String name, Object value) throws NoSuchMethodException
     {
-        support.removeProperty( name, value );
+        support.removeProperty(name, value);
     }
 
-
-    public Object getDefaultPropertyValue( String name )
+    public Object getDefaultPropertyValue(String name)
     {
-        return support.getDefaultPropertyValue( name );
+        return support.getDefaultPropertyValue(name);
     }
 
-
     public Set<String> getPropertyNames()
     {
         return support.getPropertyNames();
     }
 
-
     public Set<String> getRequiredProperties()
     {
         return Collections.emptySet();
     }
 
-    public Class<?> getPropertyType( String name ) throws NoSuchMethodException
+    public Class<?> getPropertyType(String name) throws NoSuchMethodException
     {
-        return support.getPropertyType( name );
+        return support.getPropertyType(name);
     }
 
     protected Object writeReplace()
     {
         AbstractModelElement clone = clone();
 
-        if ( clone.meta != null ) {
-            clone.serializedMeta = new HashMap<Serializable, Serializable>(clone.meta.size());
-            
-            for ( Map.Entry<Object, Object> e : clone.meta.entrySet() )
+        if (clone.meta != null)
+        {
+            clone.serializedMeta = new HashMap<Serializable, Serializable>(
+                clone.meta.size());
+
+            for (Map.Entry<Object, Object> e : clone.meta.entrySet())
             {
-                if ( e.getKey() instanceof Serializable && e.getValue() instanceof Serializable )
+                if (e.getKey() instanceof Serializable
+                    && e.getValue() instanceof Serializable)
                 {
-                    clone.serializedMeta.put( ( Serializable ) e.getKey(), ( Serializable ) e.getValue() );
+                    clone.serializedMeta.put((Serializable) e.getKey(),
+                        (Serializable) e.getValue());
                 }
             }
-    
+
             clone.meta = null;
         }
 
@@ -216,19 +203,18 @@
 
     protected Object readResolve()
     {
-        meta = serializedMeta == null ? null : new HashMap<Object, Object>( serializedMeta );
+        meta = serializedMeta == null ? null
+            : new HashMap<Object, Object>(serializedMeta);
         serializedMeta = null;
         return this;
     }
 
-
     public OverrideOptions getOverride()
     {
         return override;
     }
 
-
-    public void setOverride( OverrideOptions override )
+    public void setOverride(OverrideOptions override)
     {
         this.override = override;
     }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java
index 7ec94ef..17c830b 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
+
 package org.apache.felix.sigil.common.model;
 
 public interface ICapabilityModelElement extends IModelElement
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java
index f73b337..d2581a8 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 import java.util.Set;
 
-
 /**
  * Represents a model element that is made up of sub model elements.
  * 
@@ -38,16 +36,14 @@
      * @return
      * @throws InvalidModelException
      */
-    boolean addChild( IModelElement children ) throws InvalidModelException;
-
+    boolean addChild(IModelElement children) throws InvalidModelException;
 
     /**
      * Calls the applicable set/remove method of this model to remove the element from this part of the model
      * @param children
      * @return
      */
-    boolean removeChild( IModelElement children );
-
+    boolean removeChild(IModelElement children);
 
     /**
      * List all direct child elements of this model element.
@@ -55,14 +51,12 @@
      */
     IModelElement[] children();
 
-
     /**
      * Visits child elements of this model element, recursing down to sub compound elements when found.
      * 
      * @param walker
      */
-    void visit( IModelWalker walker );
-
+    void visit(IModelWalker walker);
 
     /**
      * Searches the model to find all child model elements which match the specified type
@@ -71,11 +65,9 @@
      * @param type
      * @return
      */
-    <T extends IModelElement> T[] childrenOfType( Class<T> type );
-
+    <T extends IModelElement> T[] childrenOfType(Class<T> type);
 
     Set<Class<? extends IModelElement>> getRequiredChildren();
 
-
     Set<Class<? extends IModelElement>> getOptionalChildren();
 }
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java
index bafc0be..84e9145 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 import java.util.Map;
 import java.util.Set;
 
-
 /**
  * IModelElement represent static information about a part of a model.
  * 
@@ -39,7 +37,6 @@
      */
     String getElementDescription();
 
-
     /**
      * A set of key value pairs designed for use by a machine to classify a particular element.
      * 
@@ -47,15 +44,13 @@
      */
     Map<Object, Object> getMeta();
 
-
     /**
      * Set meta data on this descriptor. Meta data is designed for use by a machine to classify or further enhance a
      * particular element.
      * 
      * @param meta
      */
-    void setMeta( Map<Object, Object> meta );
-
+    void setMeta(Map<Object, Object> meta);
 
     /**
      * Check to see if this element defines a complete set of properties. The definition of what constitutes a
@@ -65,16 +60,13 @@
      */
     void checkValid() throws InvalidModelException;
 
-
     /**
      * Find the parent element of this model element or null if no parent exists.
      * @return
      */
     IModelElement getParent();
 
-
-    void setParent( IModelElement parent );
-
+    void setParent(IModelElement parent);
 
     /**
      * Finds the first ancestor up the hierarch of parents which is an instance of the specified
@@ -83,33 +75,24 @@
      * @param type
      * @return
      */
-    <T extends IModelElement> T getAncestor( Class<T> type );
-
+    <T extends IModelElement> T getAncestor(Class<T> type);
 
     IModelElement clone();
 
-
     Set<String> getPropertyNames();
 
+    void setProperty(String name, Object value) throws NoSuchMethodException;
 
-    void setProperty( String name, Object value ) throws NoSuchMethodException;
+    void addProperty(String name, Object value) throws NoSuchMethodException;
 
+    void removeProperty(String name, Object value) throws NoSuchMethodException;
 
-    void addProperty( String name, Object value ) throws NoSuchMethodException;
+    Object getProperty(String name) throws NoSuchMethodException;
 
-
-    void removeProperty( String name, Object value ) throws NoSuchMethodException;
-
-
-    Object getProperty( String name ) throws NoSuchMethodException;
-
-
-    Object getDefaultPropertyValue( String name );
-
+    Object getDefaultPropertyValue(String name);
 
     Set<String> getRequiredProperties();
 
-
-    Class<?> getPropertyType( String name ) throws NoSuchMethodException;
+    Class<?> getPropertyType(String name) throws NoSuchMethodException;
 
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java
index adbecee..17993a7 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java
@@ -19,14 +19,11 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 public interface IModelInfo
 {
     String getGroupName();
 
-
     String getGroupURI();
 
-
     String getName();
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java
index 8588e48..931c72d 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 /**
  * Visitor pattern to traverse nodes in the model.
  * 
@@ -37,5 +36,5 @@
      * 
      * @return true to continue walking the model, false otherwise
      */
-    boolean visit( IModelElement element );
+    boolean visit(IModelElement element);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java
index 220e493..07c1664 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java
@@ -19,17 +19,13 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 public interface INamedModelElement extends IModelElement
 {
-    void setName( String name );
-
+    void setName(String name);
 
     String getName();
 
-
     OverrideOptions getOverride();
 
-
-    void setOverride( OverrideOptions override );
+    void setOverride(OverrideOptions override);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java
index bcf29ec..2b197f6 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java
@@ -19,16 +19,14 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 public interface IRequirementModelElement extends IModelElement
 {
-    boolean accepts( ICapabilityModelElement provider );
-    
+    boolean accepts(ICapabilityModelElement provider);
+
     /**
      * indicates whether the OSGi attribute "resolution=optional" is specified.
      */
     boolean isOptional();
 
-
-    void setOptional( boolean optional );
+    void setOptional(boolean optional);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java
index 7a67697..5f9740f 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 /**
  * @author dave
  * 
@@ -31,21 +30,18 @@
 
     private IModelElement target;
 
-
-    public InvalidModelException( IModelElement target, String msg )
+    public InvalidModelException(IModelElement target, String msg)
     {
-        super( msg );
+        super(msg);
         this.target = target;
     }
 
-
-    public InvalidModelException( IModelElement target, String msg, Throwable t )
+    public InvalidModelException(IModelElement target, String msg, Throwable t)
     {
-        super( msg, t );
+        super(msg, t);
         this.target = target;
     }
 
-
     public IModelElement getTarget()
     {
         return target;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java
index 2798753..94d36c9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 import java.util.HashMap;
 import java.util.Map;
 
-
 public abstract class ModelElementFactory
 {
     static class ElementInfo
@@ -33,8 +31,7 @@
         String groupName;
         String groupURI;
 
-
-        public ElementInfo( Class<? extends IModelElement> implType, String name, String groupName, String groupURI )
+        public ElementInfo(Class<? extends IModelElement> implType, String name, String groupName, String groupURI)
         {
             this.implType = implType;
             this.name = name;
@@ -42,34 +39,30 @@
             this.groupURI = groupURI;
         }
 
-
         public Class<? extends IModelElement> getImplType()
         {
             return implType;
         }
 
-
         public String getName()
         {
             return name;
         }
 
-
         public String getGroupName()
         {
             return groupName;
         }
 
-
         public String getGroupURI()
         {
             return groupURI;
         }
 
-
         public String toString()
         {
-            return "ElementInfo[" + name + ":" + groupName + ":" + groupURI + ":" + implType.getCanonicalName() + "]";
+            return "ElementInfo[" + name + ":" + groupName + ":" + groupURI + ":"
+                + implType.getCanonicalName() + "]";
         }
     }
 
@@ -78,25 +71,21 @@
 
         private ElementInfo e;
 
-
-        public ModelInfo( ElementInfo e )
+        public ModelInfo(ElementInfo e)
         {
             this.e = e;
         }
 
-
         public String getGroupName()
         {
             return e.getGroupName();
         }
 
-
         public String getGroupURI()
         {
             return e.getGroupURI();
         }
 
-
         public String getName()
         {
             return e.getName();
@@ -108,92 +97,88 @@
     {
         private HashMap<Class<? extends IModelElement>, ElementInfo> elementInfo = new HashMap<Class<? extends IModelElement>, ElementInfo>();
 
-
         @SuppressWarnings("unchecked")
         @Override
-        public <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException
+        public <T extends IModelElement> T newModelElement(Class<T> type)
+            throws ModelElementFactoryException
         {
-            ElementInfo info = elementInfo.get( type );
-            if ( info == null )
+            ElementInfo info = elementInfo.get(type);
+            if (info == null)
             {
-                throw new ModelElementFactoryException( "No implementation registered for " + type );
+                throw new ModelElementFactoryException(
+                    "No implementation registered for " + type);
             }
             try
             {
-                return ( T ) info.getImplType().newInstance();
+                return (T) info.getImplType().newInstance();
             }
-            catch ( InstantiationException e )
+            catch (InstantiationException e)
             {
-                throw new ModelElementFactoryException( e );
+                throw new ModelElementFactoryException(e);
             }
-            catch ( IllegalAccessException e )
+            catch (IllegalAccessException e)
             {
-                throw new ModelElementFactoryException( e );
+                throw new ModelElementFactoryException(e);
             }
         }
 
-
         @Override
-        public <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name,
-            String groupName, String groupURI )
+        public <T extends IModelElement> void register(Class<T> type,
+            Class<? extends T> impl, String name, String groupName, String groupURI)
         {
-            elementInfo.put( type, new ElementInfo( impl, name, groupName, groupURI ) );
+            elementInfo.put(type, new ElementInfo(impl, name, groupName, groupURI));
         }
 
-
         @Override
-        public <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl )
+        public <T extends IModelElement> void unregister(Class<T> type,
+            Class<? extends T> impl)
         {
-            ElementInfo info = elementInfo.get( type );
-            if ( info != null && info.getImplType() == impl )
+            ElementInfo info = elementInfo.get(type);
+            if (info != null && info.getImplType() == impl)
             {
-                elementInfo.remove( type );
+                elementInfo.remove(type);
             }
         }
 
-
         @Override
-        public IModelInfo getModelInfo( Class<? extends IModelElement> type )
+        public IModelInfo getModelInfo(Class<? extends IModelElement> type)
         {
-            ElementInfo e = findElementInfo( type );
+            ElementInfo e = findElementInfo(type);
 
-            if ( e == null )
+            if (e == null)
             {
                 return null;
             }
 
-            return new ModelInfo( e );
+            return new ModelInfo(e);
         }
 
-
         @Override
-        public IModelElement newModelElement( String namespaceURI, String localPart )
+        public IModelElement newModelElement(String namespaceURI, String localPart)
             throws ModelElementFactoryException
         {
-            for ( Map.Entry<Class<? extends IModelElement>, ElementInfo> e : elementInfo.entrySet() )
+            for (Map.Entry<Class<? extends IModelElement>, ElementInfo> e : elementInfo.entrySet())
             {
                 ElementInfo i = e.getValue();
-                if ( equal( namespaceURI, i.getGroupURI() ) && equal( i.getName(), localPart ) )
+                if (equal(namespaceURI, i.getGroupURI()) && equal(i.getName(), localPart))
                 {
-                    return newModelElement( e.getKey() );
+                    return newModelElement(e.getKey());
                 }
             }
 
             return null;
         }
 
-
-        private boolean equal( String val1, String val2 )
+        private boolean equal(String val1, String val2)
         {
-            return val1 == null ? val2 == null : val1.equals( val2 );
+            return val1 == null ? val2 == null : val1.equals(val2);
         }
 
-
-        private ElementInfo findElementInfo( Class<? extends IModelElement> type )
+        private ElementInfo findElementInfo(Class<? extends IModelElement> type)
         {
-            for ( ElementInfo e : elementInfo.values() )
+            for (ElementInfo e : elementInfo.values())
             {
-                if ( e.getImplType() == type )
+                if (e.getImplType() == type)
                 {
                     return e;
                 }
@@ -204,26 +189,22 @@
 
     }
 
-
-    public abstract <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException;
-
-
-    public abstract IModelElement newModelElement( String namespaceURI, String localPart )
+    public abstract <T extends IModelElement> T newModelElement(Class<T> type)
         throws ModelElementFactoryException;
 
+    public abstract IModelElement newModelElement(String namespaceURI, String localPart)
+        throws ModelElementFactoryException;
 
-    public abstract <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name,
-        String groupName, String groupURI );
+    public abstract <T extends IModelElement> void register(Class<T> type,
+        Class<? extends T> impl, String name, String groupName, String groupURI);
 
+    public abstract <T extends IModelElement> void unregister(Class<T> type,
+        Class<? extends T> impl);
 
-    public abstract <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl );
-
-
-    public abstract IModelInfo getModelInfo( Class<? extends IModelElement> type );
+    public abstract IModelInfo getModelInfo(Class<? extends IModelElement> type);
 
     private static ModelElementFactory instance = new DefaultModelElementFactory();
 
-
     public static ModelElementFactory getInstance()
     {
         return instance;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java
index 392b956..d6ea643 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java
@@ -19,22 +19,19 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 public class ModelElementFactoryException extends RuntimeException
 {
 
     private static final long serialVersionUID = 1L;
 
-
-    public ModelElementFactoryException( Throwable t )
+    public ModelElementFactoryException(Throwable t)
     {
-        super( t );
+        super(t);
     }
 
-
-    public ModelElementFactoryException( String msg )
+    public ModelElementFactoryException(String msg)
     {
-        super( msg );
+        super(msg);
     }
 
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java
index 1bd3757..4a88fae 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 import java.io.Serializable;
 import java.lang.ref.SoftReference;
 import java.lang.reflect.Array;
@@ -37,22 +36,17 @@
 
 import org.apache.felix.sigil.common.model.annotations.Required;
 
-
 public class ModelElementSupport implements Serializable
 {
 
-    private static final Logger log = Logger.getLogger( ModelElementSupport.class.getName() );
+    private static final Logger log = Logger.getLogger(ModelElementSupport.class.getName());
 
     private static final long serialVersionUID = 1L;
 
-    private static final PropertyAdapter[] EMPTY_PROPS = new PropertyAdapter[]
-        {};
-    private static final IModelElement[] EMPTY_ELEMENTS = new IModelElement[]
-        {};
-    private static final Object[] ZERO_ARGS = new Object[]
-        {};
-    private static final Class<?>[] ZERO_PARAMS = new Class[]
-        {};
+    private static final PropertyAdapter[] EMPTY_PROPS = new PropertyAdapter[] {};
+    private static final IModelElement[] EMPTY_ELEMENTS = new IModelElement[] {};
+    private static final Object[] ZERO_ARGS = new Object[] {};
+    private static final Class<?>[] ZERO_PARAMS = new Class[] {};
 
     private static final WeakHashMap<Class<?>, SoftReference<ChildAdapter[]>> adapterCache = new WeakHashMap<Class<?>, SoftReference<ChildAdapter[]>>();;
     private static final WeakHashMap<Class<?>, SoftReference<PropertyAdapter[]>> propertyCache = new WeakHashMap<Class<?>, SoftReference<PropertyAdapter[]>>();;
@@ -63,172 +57,168 @@
     private transient SoftReference<ChildAdapter[]> childrenReference;
     private transient SoftReference<Set<String>> propertyNameReference;
 
-
-    public ModelElementSupport( IModelElement target )
+    public ModelElementSupport(IModelElement target)
     {
         this.target = target;
     }
 
-
-    public void setProperty( String name, Object value ) throws NoSuchMethodException
+    public void setProperty(String name, Object value) throws NoSuchMethodException
     {
-        PropertyAdapter p = findProperty( name, value );
-        if ( p == null )
+        PropertyAdapter p = findProperty(name, value);
+        if (p == null)
         {
-            throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+            throw new NoSuchMethodException("No such property " + name + " for type "
+                + target.getClass());
         }
-        invoke( target, p.getWriteMethod(), value );
+        invoke(target, p.getWriteMethod(), value);
     }
 
-
-    public void addProperty( String name, Object value ) throws NoSuchMethodException
+    public void addProperty(String name, Object value) throws NoSuchMethodException
     {
-        PropertyAdapter p = findProperty( name, value );
-        if ( p == null )
+        PropertyAdapter p = findProperty(name, value);
+        if (p == null)
         {
-            throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+            throw new NoSuchMethodException("No such property " + name + " for type "
+                + target.getClass());
         }
-        invoke( target, p.getAddMethod(), value );
+        invoke(target, p.getAddMethod(), value);
     }
 
-
-    public void removeProperty( String name, Object value ) throws NoSuchMethodException
+    public void removeProperty(String name, Object value) throws NoSuchMethodException
     {
-        PropertyAdapter p = findProperty( name, value );
-        if ( p == null )
+        PropertyAdapter p = findProperty(name, value);
+        if (p == null)
         {
-            throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+            throw new NoSuchMethodException("No such property " + name + " for type "
+                + target.getClass());
         }
-        invoke( target, p.getRemoveMethod(), value );
+        invoke(target, p.getRemoveMethod(), value);
     }
 
-
-    public Object getProperty( String name ) throws NoSuchMethodException
+    public Object getProperty(String name) throws NoSuchMethodException
     {
-        PropertyAdapter p = findProperty( name, null );
-        if ( p == null )
+        PropertyAdapter p = findProperty(name, null);
+        if (p == null)
         {
-            throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+            throw new NoSuchMethodException("No such property " + name + " for type "
+                + target.getClass());
         }
-        return invoke( target, p.getReadMethod(), ZERO_ARGS );
+        return invoke(target, p.getReadMethod(), ZERO_ARGS);
     }
 
-
     public Set<String> getPropertyNames()
     {
-        Set<String> names = propertyNameReference == null ? null : propertyNameReference.get();
+        Set<String> names = propertyNameReference == null ? null
+            : propertyNameReference.get();
 
-        if ( names == null )
+        if (names == null)
         {
             names = new HashSet<String>();
 
-            PropertyAdapter[] props = cachedProps( target.getClass() );
-            for ( PropertyAdapter prop : props )
+            PropertyAdapter[] props = cachedProps(target.getClass());
+            for (PropertyAdapter prop : props)
             {
-                names.add( prop.getName() );
+                names.add(prop.getName());
             }
 
-            propertyNameReference = new SoftReference<Set<String>>( names );
+            propertyNameReference = new SoftReference<Set<String>>(names);
         }
 
         return names;
     }
 
-
-    public Object getDefaultPropertyValue( String name )
+    public Object getDefaultPropertyValue(String name)
     {
         try
         {
-            Method m = target.getClass().getMethod( makeDefaultPropertyValue( name ), ZERO_PARAMS );
-            return invoke( target, m, ZERO_ARGS );
+            Method m = target.getClass().getMethod(makeDefaultPropertyValue(name),
+                ZERO_PARAMS);
+            return invoke(target, m, ZERO_ARGS);
         }
-        catch ( SecurityException e )
+        catch (SecurityException e)
         {
-            throw new UndeclaredThrowableException( e );
+            throw new UndeclaredThrowableException(e);
         }
-        catch ( NoSuchMethodException e )
+        catch (NoSuchMethodException e)
         {
             // fine no default
             return null;
         }
     }
 
-
-    public Class<?> getPropertyType( String name ) throws NoSuchMethodException
+    public Class<?> getPropertyType(String name) throws NoSuchMethodException
     {
-        PropertyAdapter p = findProperty( name, null );
-        if ( p == null )
+        PropertyAdapter p = findProperty(name, null);
+        if (p == null)
         {
-            throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+            throw new NoSuchMethodException("No such property " + name + " for type "
+                + target.getClass());
         }
         return p.getPropertyType();
     }
 
-
     @SuppressWarnings("unchecked")
-    public <T extends IModelElement> T[] childrenOfType( Class<T> type )
+    public <T extends IModelElement> T[] childrenOfType(Class<T> type)
     {
         ChildAdapter[] adapters = cachedAdapters();
 
-        if ( adapters.length == 0 )
+        if (adapters.length == 0)
         {
             // return (T[]) EMPTY_ELEMENTS;
-            return ( ( T[] ) Array.newInstance( type, 0 ) );
+            return ((T[]) Array.newInstance(type, 0));
         }
 
         ArrayList<T> elements = new ArrayList<T>();
 
-        for ( ChildAdapter adapter : adapters )
+        for (ChildAdapter adapter : adapters)
         {
-            Collection<? extends IModelElement> val = adapter.members( target );
+            Collection<? extends IModelElement> val = adapter.members(target);
 
-            for ( IModelElement e : val )
+            for (IModelElement e : val)
             {
-                if ( type.isInstance( e ) )
+                if (type.isInstance(e))
                 {
-                    elements.add( ( T ) e );
+                    elements.add((T) e);
                 }
             }
         }
 
         //return elements.toArray( (T[]) EMPTY_ELEMENTS );
-        return elements.toArray( ( T[] ) Array.newInstance( type, elements.size() ) );
+        return elements.toArray((T[]) Array.newInstance(type, elements.size()));
     }
 
-
     public IModelElement[] children()
     {
         ChildAdapter[] adapters = cachedAdapters();
 
-        if ( adapters.length == 0 )
+        if (adapters.length == 0)
         {
             return EMPTY_ELEMENTS;
         }
 
         ArrayList<IModelElement> elements = new ArrayList<IModelElement>();
 
-        for ( ChildAdapter adapter : adapters )
+        for (ChildAdapter adapter : adapters)
         {
-            elements.addAll( adapter.members( target ) );
+            elements.addAll(adapter.members(target));
         }
 
-        return elements.toArray( EMPTY_ELEMENTS );
+        return elements.toArray(EMPTY_ELEMENTS);
     }
 
-
-    public boolean addChild( IModelElement element ) throws InvalidModelException
+    public boolean addChild(IModelElement element) throws InvalidModelException
     {
-        if ( element.getParent() == null )
+        if (element.getParent() == null)
         {
             ChildAdapter[] adapters = cachedAdapters();
 
-            if ( adapters.length > 0 )
+            if (adapters.length > 0)
             {
-                for ( ChildAdapter adapter : adapters )
+                for (ChildAdapter adapter : adapters)
                 {
-                    if ( adapter.add( target, element ) )
+                    if (adapter.add(target, element))
                     {
-                        element.setParent( target );
+                        element.setParent(target);
                         return true;
                     }
                 }
@@ -238,20 +228,19 @@
         return false;
     }
 
-
-    public boolean removeChild( IModelElement element )
+    public boolean removeChild(IModelElement element)
     {
-        if ( element.getParent() == target )
+        if (element.getParent() == target)
         {
             ChildAdapter[] adapters = cachedAdapters();
 
-            if ( adapters.length > 0 )
+            if (adapters.length > 0)
             {
-                for ( ChildAdapter adapter : adapters )
+                for (ChildAdapter adapter : adapters)
                 {
-                    if ( adapter.remove( target, element ) )
+                    if (adapter.remove(target, element))
                     {
-                        element.setParent( null );
+                        element.setParent(null);
                         return true;
                     }
                 }
@@ -261,27 +250,26 @@
         return false;
     }
 
-
-    public Set<Class<? extends IModelElement>> getChildrenTypes( boolean required )
+    public Set<Class<? extends IModelElement>> getChildrenTypes(boolean required)
     {
         ChildAdapter[] adapters = cachedAdapters();
 
-        if ( adapters.length == 0 )
+        if (adapters.length == 0)
         {
             return Collections.emptySet();
         }
 
         HashSet<Class<? extends IModelElement>> types = new HashSet<Class<? extends IModelElement>>();
 
-        for ( ChildAdapter adapter : adapters )
+        for (ChildAdapter adapter : adapters)
         {
-            if ( adapter.isRequired() == required )
+            if (adapter.isRequired() == required)
             {
                 Class<? extends IModelElement> type = adapter.getType();
 
-                if ( type != null )
+                if (type != null)
                 {
-                    types.add( type );
+                    types.add(type);
                 }
             }
         }
@@ -289,21 +277,21 @@
         return types;
     }
 
-
-    private PropertyAdapter findProperty( String name, Object value )
+    private PropertyAdapter findProperty(String name, Object value)
     {
-        PropertyAdapter[] props = propertyReference == null ? null : propertyReference.get();
+        PropertyAdapter[] props = propertyReference == null ? null
+            : propertyReference.get();
 
-        if ( props == null )
+        if (props == null)
         {
-            props = cachedProps( target.getClass() );
-            propertyReference = new SoftReference<PropertyAdapter[]>( props );
+            props = cachedProps(target.getClass());
+            propertyReference = new SoftReference<PropertyAdapter[]>(props);
         }
 
-        for ( PropertyAdapter prop : props )
+        for (PropertyAdapter prop : props)
         {
-            if ( prop.getName().equals( name )
-                && ( value == null || prop.getRawType().isAssignableFrom( value.getClass() ) ) )
+            if (prop.getName().equals(name)
+                && (value == null || prop.getRawType().isAssignableFrom(value.getClass())))
             {
                 return prop;
             }
@@ -312,152 +300,144 @@
         return null;
     }
 
-
-    private static synchronized PropertyAdapter[] cachedProps( Class<? extends IModelElement> type )
+    private static synchronized PropertyAdapter[] cachedProps(
+        Class<? extends IModelElement> type)
     {
-        SoftReference<PropertyAdapter[]> ref = propertyCache.get( type );
+        SoftReference<PropertyAdapter[]> ref = propertyCache.get(type);
 
         PropertyAdapter[] props = ref == null ? null : ref.get();
 
-        if ( props == null )
+        if (props == null)
         {
-            props = loadProps( type );
-            propertyCache.put( type, new SoftReference<PropertyAdapter[]>( props ) );
+            props = loadProps(type);
+            propertyCache.put(type, new SoftReference<PropertyAdapter[]>(props));
         }
 
         return props;
     }
 
-
-    private static PropertyAdapter[] loadProps( Class<? extends IModelElement> type )
+    private static PropertyAdapter[] loadProps(Class<? extends IModelElement> type)
     {
         ArrayList<PropertyAdapter> props = new ArrayList<PropertyAdapter>();
-        for ( Method m : type.getMethods() )
+        for (Method m : type.getMethods())
         {
-            if ( isValidProperty( m ) )
+            if (isValidProperty(m))
             {
                 try
                 {
-                    PropertyAdapter p = new PropertyAdapter( m, type );
-                    props.add( p );
+                    PropertyAdapter p = new PropertyAdapter(m, type);
+                    props.add(p);
                 }
-                catch ( NoSuchMethodException e )
+                catch (NoSuchMethodException e)
                 {
                     // fine not a bean method
-                    log.finer( "Invalid bean property method " + m + ": " + e.getMessage() );
+                    log.finer("Invalid bean property method " + m + ": " + e.getMessage());
                 }
             }
         }
 
-        return props.toArray( EMPTY_PROPS );
+        return props.toArray(EMPTY_PROPS);
     }
 
-
-    private static boolean isValidProperty( Method m )
+    private static boolean isValidProperty(Method m)
     {
-        return m.getName().startsWith( "get" ) && m.getParameterTypes().length == 0
-            && !m.getDeclaringClass().equals( Object.class )
-            && !IModelElement.class.isAssignableFrom( m.getReturnType() );
+        return m.getName().startsWith("get") && m.getParameterTypes().length == 0
+            && !m.getDeclaringClass().equals(Object.class)
+            && !IModelElement.class.isAssignableFrom(m.getReturnType());
     }
 
-
-    private static String makeDefaultPropertyValue( String name )
+    private static String makeDefaultPropertyValue(String name)
     {
-        return "getDefault" + capitalise( name );
+        return "getDefault" + capitalise(name);
     }
 
-
-    private static String capitalise( String name )
+    private static String capitalise(String name)
     {
-        return Character.toUpperCase( name.charAt( 0 ) ) + name.substring( 1 );
+        return Character.toUpperCase(name.charAt(0)) + name.substring(1);
     }
 
-
-    private static String decapitalise( String substring )
+    private static String decapitalise(String substring)
     {
-        return Character.toLowerCase( substring.charAt( 0 ) ) + substring.substring( 1 );
+        return Character.toLowerCase(substring.charAt(0)) + substring.substring(1);
     }
 
-
     private ChildAdapter[] cachedAdapters()
     {
-        ChildAdapter[] adapters = childrenReference == null ? null : childrenReference.get();
+        ChildAdapter[] adapters = childrenReference == null ? null
+            : childrenReference.get();
 
-        if ( adapters == null )
+        if (adapters == null)
         {
-            adapters = loadAdapters( target );
-            childrenReference = new SoftReference<ChildAdapter[]>( adapters );
+            adapters = loadAdapters(target);
+            childrenReference = new SoftReference<ChildAdapter[]>(adapters);
         }
 
         return adapters;
     }
 
-
-    private static synchronized ChildAdapter[] loadAdapters( IModelElement target )
+    private static synchronized ChildAdapter[] loadAdapters(IModelElement target)
     {
         Class<? extends IModelElement> type = target.getClass();
-        SoftReference<ChildAdapter[]> ref = adapterCache.get( type );
+        SoftReference<ChildAdapter[]> ref = adapterCache.get(type);
 
         ChildAdapter[] adapters = ref == null ? null : ref.get();
 
-        if ( adapters == null )
+        if (adapters == null)
         {
-            adapters = buildAdapters( type );
-            adapterCache.put( type, new SoftReference<ChildAdapter[]>( adapters ) );
+            adapters = buildAdapters(type);
+            adapterCache.put(type, new SoftReference<ChildAdapter[]>(adapters));
         }
 
         return adapters;
     }
 
-
-    private static ChildAdapter[] buildAdapters( Class<? extends IModelElement> type )
+    private static ChildAdapter[] buildAdapters(Class<? extends IModelElement> type)
     {
         ArrayList<ChildAdapter> adapters = new ArrayList<ChildAdapter>();
 
-        for ( Method m : type.getMethods() )
+        for (Method m : type.getMethods())
         {
             ChildAdapter adapter = null;
 
-            if ( isValidGetProperty( m ) )
+            if (isValidGetProperty(m))
             {
-                adapter = buildGetAdapter( m );
+                adapter = buildGetAdapter(m);
             }
-            else if ( isValidSetProperty( m ) )
+            else if (isValidSetProperty(m))
             {
-                adapter = buildSetAdapter( m );
+                adapter = buildSetAdapter(m);
             }
-            else if ( isValidAddProperty( m ) )
+            else if (isValidAddProperty(m))
             {
-                adapter = buildAddAdapter( m );
+                adapter = buildAddAdapter(m);
             }
-            else if ( isValidRemoveProperty( m ) )
+            else if (isValidRemoveProperty(m))
             {
-                adapter = buildRemoveAdapter( m );
+                adapter = buildRemoveAdapter(m);
             }
 
-            if ( adapter != null )
+            if (adapter != null)
             {
-                adapters.add( adapter );
+                adapters.add(adapter);
             }
         }
 
-        return adapters.toArray( new ChildAdapter[adapters.size()] );
+        return adapters.toArray(new ChildAdapter[adapters.size()]);
     }
 
-
-    private static ChildAdapter buildGetAdapter( Method m )
+    private static ChildAdapter buildGetAdapter(Method m)
     {
-        if ( IModelElement.class.isAssignableFrom( m.getReturnType() ) )
+        if (IModelElement.class.isAssignableFrom(m.getReturnType()))
         {
-            return new GetPropertyAdapter( m );
+            return new GetPropertyAdapter(m);
         }
-        else if ( Collection.class.isAssignableFrom( m.getReturnType() ) )
+        else if (Collection.class.isAssignableFrom(m.getReturnType()))
         {
-            return new GetCollectionAdapter( m );
+            return new GetCollectionAdapter(m);
         }
-        else if ( isModelArray( m.getReturnType() ) )
+        else if (isModelArray(m.getReturnType()))
         {
-            return new GetArrayAdapter( m );
+            return new GetArrayAdapter(m);
         }
         else
         {
@@ -465,12 +445,11 @@
         }
     }
 
-
-    private static ChildAdapter buildSetAdapter( Method m )
+    private static ChildAdapter buildSetAdapter(Method m)
     {
-        if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+        if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
         {
-            return new SetPropertyAdapter( m );
+            return new SetPropertyAdapter(m);
         }
         else
         {
@@ -478,12 +457,11 @@
         }
     }
 
-
-    private static ChildAdapter buildAddAdapter( Method m )
+    private static ChildAdapter buildAddAdapter(Method m)
     {
-        if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+        if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
         {
-            return new AddPropertyAdapter( m );
+            return new AddPropertyAdapter(m);
         }
         else
         {
@@ -491,12 +469,11 @@
         }
     }
 
-
-    private static ChildAdapter buildRemoveAdapter( Method m )
+    private static ChildAdapter buildRemoveAdapter(Method m)
     {
-        if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+        if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
         {
-            return new RemovePropertyAdapter( m );
+            return new RemovePropertyAdapter(m);
         }
         else
         {
@@ -504,71 +481,66 @@
         }
     }
 
-
-    private static boolean isValidRemoveProperty( Method m )
+    private static boolean isValidRemoveProperty(Method m)
     {
-        return m.getParameterTypes().length == 1 && m.getName().startsWith( "remove" )
-            && !isDeclared( ICompoundModelElement.class, m );
+        return m.getParameterTypes().length == 1 && m.getName().startsWith("remove")
+            && !isDeclared(ICompoundModelElement.class, m);
     }
 
-
-    private static boolean isValidAddProperty( Method m )
+    private static boolean isValidAddProperty(Method m)
     {
-        return m.getParameterTypes().length == 1 && m.getName().startsWith( "add" )
-            && !isDeclared( ICompoundModelElement.class, m );
+        return m.getParameterTypes().length == 1 && m.getName().startsWith("add")
+            && !isDeclared(ICompoundModelElement.class, m);
     }
 
-
-    private static boolean isDeclared( Class<? extends IModelElement> element, Method m )
+    private static boolean isDeclared(Class<? extends IModelElement> element, Method m)
     {
         try
         {
-            element.getMethod( m.getName(), m.getParameterTypes() );
+            element.getMethod(m.getName(), m.getParameterTypes());
             return true;
         }
-        catch ( SecurityException e )
+        catch (SecurityException e)
         {
-            throw new UndeclaredThrowableException( e );
+            throw new UndeclaredThrowableException(e);
         }
-        catch ( NoSuchMethodException e )
+        catch (NoSuchMethodException e)
         {
             return false;
         }
     }
 
-
-    private static boolean isValidSetProperty( Method m )
+    private static boolean isValidSetProperty(Method m)
     {
-        return m.getParameterTypes().length == 1 && m.getName().startsWith( "set" )
-            && !isDeclared( IModelElement.class, m );
+        return m.getParameterTypes().length == 1 && m.getName().startsWith("set")
+            && !isDeclared(IModelElement.class, m);
     }
 
-
-    private static boolean isValidGetProperty( Method m )
+    private static boolean isValidGetProperty(Method m)
     {
-        return m.getParameterTypes().length == 0 && m.getName().startsWith( "get" )
-            && !isDeclared( IModelElement.class, m ) && !isDeclared( ICompoundModelElement.class, m );
+        return m.getParameterTypes().length == 0 && m.getName().startsWith("get")
+            && !isDeclared(IModelElement.class, m)
+            && !isDeclared(ICompoundModelElement.class, m);
     }
 
-
-    private static Object invoke( Object target, Method m, Object... args )
+    private static Object invoke(Object target, Method m, Object... args)
     {
         try
         {
-            return m.invoke( target, args );
+            return m.invoke(target, args);
         }
-        catch ( IllegalArgumentException e )
+        catch (IllegalArgumentException e)
         {
             // this should already have been tested
-            throw new IllegalStateException( e );
+            throw new IllegalStateException(e);
         }
-        catch ( IllegalAccessException e )
+        catch (IllegalAccessException e)
         {
-            throw new UndeclaredThrowableException( e );
+            throw new UndeclaredThrowableException(e);
         }
-        catch ( InvocationTargetException e )
+        catch (InvocationTargetException e)
         {
-            throw new UndeclaredThrowableException( e.getCause() );
+            throw new UndeclaredThrowableException(e.getCause());
         }
     }
 
@@ -583,138 +555,131 @@
         Method r;
         Class<?> propertyType;
 
-
-        public PropertyAdapter( Method g, Class<?> type ) throws SecurityException, NoSuchMethodException
+        public PropertyAdapter(Method g, Class<?> type) throws SecurityException, NoSuchMethodException
         {
-            if ( g.getReturnType().isArray() || Iterable.class.isAssignableFrom( g.getReturnType() ) )
+            if (g.getReturnType().isArray()
+                || Iterable.class.isAssignableFrom(g.getReturnType()))
             {
-                prop = g.getName().substring( 3 );
+                prop = g.getName().substring(3);
                 // remove trailing s - as in addWibble, removeWibble, getWibbles
-                prop = prop.substring( 0, prop.length() - 1 );
-                name = decapitalise( prop );
-                a = find( "add", prop, g.getReturnType(), type );
+                prop = prop.substring(0, prop.length() - 1);
+                name = decapitalise(prop);
+                a = find("add", prop, g.getReturnType(), type);
                 propertyType = a.getParameterTypes()[0];
-                r = find( "remove", prop, g.getReturnType(), type );
-                if ( r.getParameterTypes()[0] != propertyType )
+                r = find("remove", prop, g.getReturnType(), type);
+                if (r.getParameterTypes()[0] != propertyType)
                 {
-                    throw new NoSuchMethodException( "Add remove property method types do not match" );
+                    throw new NoSuchMethodException(
+                        "Add remove property method types do not match");
                 }
-                propertyType = Array.newInstance( propertyType, 0 ).getClass();
+                propertyType = Array.newInstance(propertyType, 0).getClass();
             }
             else
             {
-                prop = g.getName().substring( 3 );
-                name = decapitalise( prop );
+                prop = g.getName().substring(3);
+                name = decapitalise(prop);
                 propertyType = g.getReturnType();
-                s = find( "set", prop, propertyType, type );
+                s = find("set", prop, propertyType, type);
             }
 
             this.g = g;
         }
 
-
         public Class<?> getRawType()
         {
-            return propertyType.isArray() ? propertyType.getComponentType() : propertyType;
+            return propertyType.isArray() ? propertyType.getComponentType()
+                : propertyType;
         }
 
-
         public Class<?> getPropertyType()
         {
             return propertyType;
         }
 
-
         public Method getReadMethod()
         {
             return g;
         }
 
-
         public Method getAddMethod() throws NoSuchMethodException
         {
-            if ( a == null )
+            if (a == null)
             {
-                throw new NoSuchMethodException( "No such method add" + prop );
+                throw new NoSuchMethodException("No such method add" + prop);
             }
 
             return a;
         }
 
-
         public Method getRemoveMethod() throws NoSuchMethodException
         {
-            if ( r == null )
+            if (r == null)
             {
-                throw new NoSuchMethodException( "No such method remove" + prop );
+                throw new NoSuchMethodException("No such method remove" + prop);
             }
 
             return r;
         }
 
-
         public Method getWriteMethod() throws NoSuchMethodException
         {
-            if ( s == null )
+            if (s == null)
             {
-                throw new NoSuchMethodException( "No such method set" + prop );
+                throw new NoSuchMethodException("No such method set" + prop);
             }
 
             return s;
         }
 
-
         @Override
         public String toString()
         {
             return "PropertyAdapter[" + name + "]";
         }
 
-
-        private Method find( String prefix, String prop, Class<?> returnType, Class<?> type ) throws SecurityException,
-            NoSuchMethodException
+        private Method find(String prefix, String prop, Class<?> returnType, Class<?> type)
+            throws SecurityException, NoSuchMethodException
         {
             String methodName = prefix + prop;
 
-            if ( returnType.isArray() )
+            if (returnType.isArray())
             {
                 Class<?> t = returnType.getComponentType();
-                return type.getMethod( methodName, new Class[]
-                    { t } );
+                return type.getMethod(methodName, new Class[] { t });
             }
-            else if ( Iterable.class.isAssignableFrom( returnType ) )
+            else if (Iterable.class.isAssignableFrom(returnType))
             {
                 Method f = null;
-                for ( Method m : type.getMethods() )
+                for (Method m : type.getMethods())
                 {
-                    if ( m.getParameterTypes().length == 1 && m.getName().equals( methodName )
-                        && !IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+                    if (m.getParameterTypes().length == 1
+                        && m.getName().equals(methodName)
+                        && !IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
                     {
-                        if ( f == null )
+                        if (f == null)
                         {
                             f = m;
                         }
                         else
                         {
-                            throw new NoSuchMethodException( "Found duplicate " + methodName );
+                            throw new NoSuchMethodException("Found duplicate "
+                                + methodName);
                         }
                     }
                 }
-                if ( f == null )
+                if (f == null)
                 {
-                    throw new NoSuchMethodException( "No such method " + methodName );
+                    throw new NoSuchMethodException("No such method " + methodName);
                 }
 
                 return f;
             }
             else
             {
-                return type.getMethod( methodName, new Class[]
-                    { returnType } );
+                return type.getMethod(methodName, new Class[] { returnType });
             }
         }
 
-
         public String getName()
         {
             return name;
@@ -726,40 +691,33 @@
     {
         Method m;
 
-
-        ChildAdapter( Method m )
+        ChildAdapter(Method m)
         {
             this.m = m;
         }
 
-
         public boolean isRequired()
         {
-            return m.isAnnotationPresent( Required.class );
+            return m.isAnnotationPresent(Required.class);
         }
 
-
-        boolean add( Object target, IModelElement element )
+        boolean add(Object target, IModelElement element)
         {
             return false;
         }
 
-
         abstract Class<? extends IModelElement> getType();
 
-
-        boolean remove( Object target, IModelElement element )
+        boolean remove(Object target, IModelElement element)
         {
             return false;
         }
 
-
-        Collection<? extends IModelElement> members( Object target )
+        Collection<? extends IModelElement> members(Object target)
         {
             return Collections.emptyList();
         }
 
-
         @Override
         public String toString()
         {
@@ -769,67 +727,64 @@
 
     private static class GetPropertyAdapter extends ChildAdapter
     {
-        GetPropertyAdapter( Method m )
+        GetPropertyAdapter(Method m)
         {
-            super( m );
+            super(m);
         }
 
-
         @Override
-        Collection<? extends IModelElement> members( Object target )
+        Collection<? extends IModelElement> members(Object target)
         {
-            IModelElement member = ( IModelElement ) invoke( target, m, ZERO_ARGS );
-            if ( member == null )
+            IModelElement member = (IModelElement) invoke(target, m, ZERO_ARGS);
+            if (member == null)
             {
                 return Collections.emptyList();
             }
             else
             {
-                return Collections.<IModelElement> singleton( member );
+                return Collections.<IModelElement> singleton(member);
             }
         }
 
-
         @SuppressWarnings("unchecked")
         @Override
         Class<? extends IModelElement> getType()
         {
-            return ( Class<? extends IModelElement> ) m.getReturnType();
+            return (Class<? extends IModelElement>) m.getReturnType();
         }
     }
 
     private static class GetCollectionAdapter extends ChildAdapter
     {
-        public GetCollectionAdapter( Method m )
+        public GetCollectionAdapter(Method m)
         {
-            super( m );
+            super(m);
         }
 
-
         @SuppressWarnings("unchecked")
         @Override
-        Collection<? extends IModelElement> members( Object target )
+        Collection<? extends IModelElement> members(Object target)
         {
-            Collection members = ( Collection ) invoke( target, m, ZERO_ARGS );
-            if ( members == null )
+            Collection members = (Collection) invoke(target, m, ZERO_ARGS);
+            if (members == null)
             {
                 return Collections.emptyList();
             }
             else
             {
-                ArrayList<IModelElement> safe = new ArrayList<IModelElement>( members.size() );
-                for ( Object o : members )
+                ArrayList<IModelElement> safe = new ArrayList<IModelElement>(
+                    members.size());
+                for (Object o : members)
                 {
-                    if ( o instanceof IModelElement )
+                    if (o instanceof IModelElement)
                     {
-                        safe.add( ( IModelElement ) o );
+                        safe.add((IModelElement) o);
                     }
                 }
                 return safe;
             }
         }
 
-
         @Override
         Class<? extends IModelElement> getType()
         {
@@ -841,50 +796,46 @@
 
     private static class GetArrayAdapter extends ChildAdapter
     {
-        public GetArrayAdapter( Method m )
+        public GetArrayAdapter(Method m)
         {
-            super( m );
+            super(m);
         }
 
-
         @Override
-        Collection<? extends IModelElement> members( Object target )
+        Collection<? extends IModelElement> members(Object target)
         {
-            IModelElement[] array = ( IModelElement[] ) invoke( target, m, ZERO_ARGS );
-            if ( array == null || array.length == 0 )
+            IModelElement[] array = (IModelElement[]) invoke(target, m, ZERO_ARGS);
+            if (array == null || array.length == 0)
             {
                 return Collections.emptyList();
             }
             else
             {
-                return ( Collection<? extends IModelElement> ) Arrays.asList( array );
+                return (Collection<? extends IModelElement>) Arrays.asList(array);
             }
         }
 
-
         @SuppressWarnings("unchecked")
         @Override
         Class<? extends IModelElement> getType()
         {
-            return ( Class<? extends IModelElement> ) m.getReturnType().getComponentType();
+            return (Class<? extends IModelElement>) m.getReturnType().getComponentType();
         }
     }
 
     private static class SetPropertyAdapter extends ChildAdapter
     {
-        public SetPropertyAdapter( Method m )
+        public SetPropertyAdapter(Method m)
         {
-            super( m );
+            super(m);
         }
 
-
         @Override
-        boolean add( Object target, IModelElement element )
+        boolean add(Object target, IModelElement element)
         {
-            if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+            if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
             {
-                invoke( target, m, new Object[]
-                    { element } );
+                invoke(target, m, new Object[] { element });
                 return true;
             }
             else
@@ -893,14 +844,12 @@
             }
         }
 
-
         @Override
-        boolean remove( Object target, IModelElement element )
+        boolean remove(Object target, IModelElement element)
         {
-            if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+            if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
             {
-                invoke( target, m, new Object[]
-                    { null } );
+                invoke(target, m, new Object[] { null });
                 return true;
             }
             else
@@ -909,30 +858,27 @@
             }
         }
 
-
         @SuppressWarnings("unchecked")
         @Override
         Class<? extends IModelElement> getType()
         {
-            return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+            return (Class<? extends IModelElement>) m.getParameterTypes()[0];
         }
     }
 
     private static class AddPropertyAdapter extends ChildAdapter
     {
-        public AddPropertyAdapter( Method m )
+        public AddPropertyAdapter(Method m)
         {
-            super( m );
+            super(m);
         }
 
-
         @Override
-        boolean add( Object target, IModelElement element )
+        boolean add(Object target, IModelElement element)
         {
-            if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+            if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
             {
-                invoke( target, m, new Object[]
-                    { element } );
+                invoke(target, m, new Object[] { element });
                 return true;
             }
             else
@@ -941,31 +887,28 @@
             }
         }
 
-
         @SuppressWarnings("unchecked")
         @Override
         Class<? extends IModelElement> getType()
         {
-            return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+            return (Class<? extends IModelElement>) m.getParameterTypes()[0];
         }
     }
 
     private static class RemovePropertyAdapter extends ChildAdapter
     {
 
-        public RemovePropertyAdapter( Method m )
+        public RemovePropertyAdapter(Method m)
         {
-            super( m );
+            super(m);
         }
 
-
         @Override
-        boolean remove( Object target, IModelElement element )
+        boolean remove(Object target, IModelElement element)
         {
-            if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+            if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
             {
-                invoke( target, m, new Object[]
-                    { element } );
+                invoke(target, m, new Object[] { element });
                 return true;
             }
             else
@@ -974,18 +917,17 @@
             }
         }
 
-
         @SuppressWarnings("unchecked")
         @Override
         Class<? extends IModelElement> getType()
         {
-            return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+            return (Class<? extends IModelElement>) m.getParameterTypes()[0];
         }
     }
 
-
-    private static boolean isModelArray( Class<?> returnType )
+    private static boolean isModelArray(Class<?> returnType)
     {
-        return returnType.isArray() && IModelElement.class.isAssignableFrom( returnType.getComponentType() );
+        return returnType.isArray()
+            && IModelElement.class.isAssignableFrom(returnType.getComponentType());
     }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java
index 65b7387..66a60f9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.common.model;
 
-
 import java.util.HashMap;
 import java.util.Map;
 
-
 /**
  * @author dave
  * 
@@ -38,32 +36,29 @@
 
     static
     {
-        for ( OverrideOptions option : OverrideOptions.values() )
+        for (OverrideOptions option : OverrideOptions.values())
         {
-            map.put( option.str.toLowerCase(), option );
+            map.put(option.str.toLowerCase(), option);
         }
     }
 
-
-    private OverrideOptions( String str )
+    private OverrideOptions(String str)
     {
         this.str = str;
     }
 
-
-    public static OverrideOptions parse( String val )
+    public static OverrideOptions parse(String val)
     {
-        OverrideOptions option = map.get( val.toLowerCase() );
+        OverrideOptions option = map.get(val.toLowerCase());
 
-        if ( option == null )
+        if (option == null)
         {
-            throw new IllegalArgumentException( "Invalid override value " + val );
+            throw new IllegalArgumentException("Invalid override value " + val);
         }
 
         return option;
     }
 
-
     @Override
     public String toString()
     {
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java
index a5cc98a..592c21b 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.model.annotations;
 
-
 import java.lang.annotation.Documented;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Inherited;
@@ -27,7 +26,6 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-
 @Inherited
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java
index 0053fd0..5765be9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java
@@ -24,5 +24,6 @@
 public interface IBundleCapability extends ICapabilityModelElement
 {
     String getSymbolicName();
+
     Version getVersion();
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java
index b9b406d..d333fe1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java
@@ -19,33 +19,25 @@
 
 package org.apache.felix.sigil.common.model.eclipse;
 
-
 import java.util.Collection;
 
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.osgi.framework.Version;
 
-
 public interface ILibrary extends IModelElement
 {
     String getName();
 
-
-    void setName( String name );
-
+    void setName(String name);
 
     Version getVersion();
 
+    void setVersion(Version version);
 
-    void setVersion( Version version );
+    void addImport(IPackageImport pi);
 
-
-    void addImport( IPackageImport pi );
-
-
-    void removeImport( IPackageImport pi );
-
+    void removeImport(IPackageImport pi);
 
     Collection<IPackageImport> getImports();
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java
index 5e9b9d4..c1818f9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java
@@ -19,21 +19,16 @@
 
 package org.apache.felix.sigil.common.model.eclipse;
 
-
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.osgi.VersionRange;
 
-
 public interface ILibraryImport extends IModelElement
 {
     String getLibraryName();
 
-
-    void setLibraryName( String name );
-
+    void setLibraryName(String name);
 
     VersionRange getVersions();
 
-
-    void setVersions( VersionRange range );
+    void setVersions(VersionRange range);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java
index 812e3dd..5dcde31 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.model.eclipse;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
@@ -32,94 +31,70 @@
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.model.osgi.IVersionedModelElement;
 
-
 /**
  * @author dave
  *
  */
 public interface ISigilBundle extends ICompoundModelElement, IVersionedModelElement
 {
-    void synchronize( IProgressMonitor monitor ) throws IOException;
-
+    void synchronize(IProgressMonitor monitor) throws IOException;
 
     boolean isSynchronized();
 
-
     IBundleModelElement getBundleInfo();
 
-
     String getSymbolicName();
 
-
-    void setBundleInfo( IBundleModelElement bundle );
-
+    void setBundleInfo(IBundleModelElement bundle);
 
     // TODO rename this method...
-    void addSourcePath( Resource path );
+    void addSourcePath(Resource path);
 
-
-    void removeSourcePath( Resource path );
-
+    void removeSourcePath(Resource path);
 
     Collection<Resource> getSourcePaths();
 
-
     void clearSourcePaths();
 
-
     Collection<String> getClasspathEntrys();
 
+    void addClasspathEntry(String encodedClasspath);
 
-    void addClasspathEntry( String encodedClasspath );
-
-
-    void removeClasspathEntry( String encodedClasspath );
-
+    void removeClasspathEntry(String encodedClasspath);
 
     // XXX must be file due to SiglCore.isBundlePath
     File getLocation();
 
-
     // XXX must be file due to SiglCore.isBundlePath
-    void setLocation( File location );
-
+    void setLocation(File location);
 
     File getSourcePathLocation();
 
-
-    void setSourcePathLocation( File location );
-
+    void setSourcePathLocation(File location);
 
     String getSourceRootPath();
 
+    void setSourceRootPath(String location);
 
-    void setSourceRootPath( String location );
-
-
-    void setLicencePathLocation( File cacheSourceLocation );
-
+    void setLicencePathLocation(File cacheSourceLocation);
 
     File getLicencePathLocation();
 
-
     /**
      * get package names included in bundle.
      * Can contain wildcards e.g. org.foo.*
      */
     Collection<String> getPackages();
 
-
     /**
      * remove package name from those included in bundle.
      */
-    boolean removePackage( String pkg );
-
+    boolean removePackage(String pkg);
 
     /**
      * add package name to be included in bundle.
      */
-    void addPackage( String pkg );
-
+    void addPackage(String pkg);
 
     /**
      * Attempt to find a package export that matches the given name or return null if none specified
@@ -127,16 +102,14 @@
      * @param elementName
      * @return
      */
-    IPackageExport findExport( String elementName );
-
+    IPackageExport findExport(String elementName);
 
     /**
      * Attempt to find a package import that matches the given name or return null if none specified
      * @param packageName
      * @return
      */
-    IPackageImport findImport( String packageName );
-
+    IPackageImport findImport(String packageName);
 
     IBundleCapability getBundleCapability();
 }
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java
index cc17142..653f683 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.model.osgi;
 
-
 import java.net.URI;
 import java.util.Collection;
 import java.util.Set;
@@ -29,129 +28,88 @@
 import org.apache.felix.sigil.common.model.eclipse.ILibraryImport;
 import org.osgi.framework.Version;
 
-
 public interface IBundleModelElement extends INamedModelElement, ICompoundModelElement, IVersionedModelElement
 {
 
     String getActivator();
 
-
-    void setActivator( String activator );
-
+    void setActivator(String activator);
 
     String getCategory();
 
-
-    void setCategory( String category );
-
+    void setCategory(String category);
 
     String getContactAddress();
 
-
-    void setContactAddress( String contactAddress );
-
+    void setContactAddress(String contactAddress);
 
     String getCopyright();
 
-
-    void setCopyright( String copyright );
-
+    void setCopyright(String copyright);
 
     URI getDocURI();
 
-
-    void setDocURI( URI docURI );
-
+    void setDocURI(URI docURI);
 
     Collection<IPackageExport> getExports();
 
+    void addExport(IPackageExport packageExport);
 
-    void addExport( IPackageExport packageExport );
-
-
-    void removeExport( IPackageExport packageExport );
-
+    void removeExport(IPackageExport packageExport);
 
     Collection<IPackageImport> getImports();
 
+    void addImport(IPackageImport packageImport);
 
-    void addImport( IPackageImport packageImport );
-
-
-    void removeImport( IPackageImport packageImport );
-
+    void removeImport(IPackageImport packageImport);
 
     Collection<IRequiredBundle> getRequiredBundles();
 
+    void addRequiredBundle(IRequiredBundle bundle);
 
-    void addRequiredBundle( IRequiredBundle bundle );
+    void removeRequiredBundle(IRequiredBundle bundle);
 
+    void addLibraryImport(ILibraryImport library);
 
-    void removeRequiredBundle( IRequiredBundle bundle );
-
-
-    void addLibraryImport( ILibraryImport library );
-
-
-    void removeLibraryImport( ILibraryImport library );
-
+    void removeLibraryImport(ILibraryImport library);
 
     Set<ILibraryImport> getLibraryImports();
 
-
     URI getLicenseURI();
 
-
-    void setLicenseURI( URI licenseURI );
-
+    void setLicenseURI(URI licenseURI);
 
     URI getSourceLocation();
 
-
-    void setSourceLocation( URI sourceLocation );
-
+    void setSourceLocation(URI sourceLocation);
 
     String getSymbolicName();
 
-
-    void setSymbolicName( String symbolicName );
-
+    void setSymbolicName(String symbolicName);
 
     URI getUpdateLocation();
 
-
-    void setUpdateLocation( URI updateLocation );
-
+    void setUpdateLocation(URI updateLocation);
 
     String getVendor();
 
-
-    void setVendor( String vendor );
-
+    void setVendor(String vendor);
 
     Version getVersion();
 
+    void setVersion(Version version);
 
-    void setVersion( Version version );
-
-
-    void setDescription( String elementText );
-
+    void setDescription(String elementText);
 
     String getDescription();
 
-
     Collection<String> getClasspaths();
 
+    void addClasspath(String path);
 
-    void addClasspath( String path );
+    void removeClasspath(String path);
 
-
-    void removeClasspath( String path );
-
-
-    void setFragmentHost( IRequiredBundle fragmentHost );
-
+    void setFragmentHost(IRequiredBundle fragmentHost);
 
     IRequiredBundle getFragmentHost();
 }
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java
index 4ad7879..5f27980 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java
@@ -19,26 +19,20 @@
 
 package org.apache.felix.sigil.common.model.osgi;
 
-
 import java.util.Collection;
 
 import org.apache.felix.sigil.common.model.ICapabilityModelElement;
 import org.osgi.framework.Version;
 
-
 public interface IPackageExport extends IPackageModelElement, IVersionedModelElement, Comparable<IPackageExport>, ICapabilityModelElement
 {
-    void addUse( String uses );
+    void addUse(String uses);
 
-
-    void removeUse( String uses );
-
+    void removeUse(String uses);
 
     Collection<String> getUses();
 
-
-    void setUses( Collection<String> asList );
-
+    void setUses(Collection<String> asList);
 
     Version getRawVersion();
 }
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java
index 8c10cd5..2ddc6dd 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java
@@ -19,12 +19,9 @@
 
 package org.apache.felix.sigil.common.model.osgi;
 
-
 import org.apache.felix.sigil.common.model.IRequirementModelElement;
 
-
-public interface IPackageImport extends IPackageModelElement, IVersionRangeModelElement, IRequirementModelElement,
-    Comparable<IPackageImport>
+public interface IPackageImport extends IPackageModelElement, IVersionRangeModelElement, IRequirementModelElement, Comparable<IPackageImport>
 {
     /**
      * indicates whether import is needed at compile-time.
@@ -33,9 +30,7 @@
      */
     boolean isDependency();
 
-
-    void setDependency( boolean dependency );
-
+    void setDependency(boolean dependency);
 
     /**
      * indicates whether import should be added to OSGi Package-Import header.
@@ -43,8 +38,7 @@
      */
     OSGiImport getOSGiImport();
 
-
-    void setOSGiImport( OSGiImport osgiImport );
+    void setOSGiImport(OSGiImport osgiImport);
 
     enum OSGiImport
     {
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java
index c50b2c1..e236e4e 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java
@@ -19,16 +19,13 @@
 
 package org.apache.felix.sigil.common.model.osgi;
 
-
 import org.apache.felix.sigil.common.model.IModelElement;
 
-
 public interface IPackageModelElement extends IModelElement
 {
 
     String getPackageName();
 
-
-    void setPackageName( String packageName );
+    void setPackageName(String packageName);
 
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java
index e425fdc..9c706a0 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java
@@ -19,22 +19,17 @@
 
 package org.apache.felix.sigil.common.model.osgi;
 
-
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.model.IRequirementModelElement;
 import org.apache.felix.sigil.common.osgi.VersionRange;
 
-
 public interface IRequiredBundle extends IModelElement, IRequirementModelElement, Comparable<IRequiredBundle>
 {
     String getSymbolicName();
 
-
-    void setSymbolicName( String symbolicName );
-
+    void setSymbolicName(String symbolicName);
 
     VersionRange getVersions();
 
-
-    void setVersions( VersionRange versions );
+    void setVersions(VersionRange versions);
 }
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java
index 60c1d6b..fe069ad 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java
@@ -26,7 +26,6 @@
 
     VersionRange getVersions();
 
-
-    void setVersions( VersionRange version );
+    void setVersions(VersionRange version);
 
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java
index cfe75d2..8b88b13 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java
@@ -19,16 +19,13 @@
 
 package org.apache.felix.sigil.common.model.osgi;
 
-
 import org.osgi.framework.Version;
 
-
 public interface IVersionedModelElement
 {
 
     Version getVersion();
 
-
-    void setVersion( Version version );
+    void setVersion(Version version);
 
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java
index dc397f0..c55e73b 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -39,89 +38,79 @@
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
 
-
 public abstract class AbstractBundleRepository implements IBundleRepository
 {
 
     private final String id;
     private final HashSet<IBundleRepositoryListener> listeners = new HashSet<IBundleRepositoryListener>();
 
-
-    public AbstractBundleRepository( String id )
+    public AbstractBundleRepository(String id)
     {
         this.id = id;
     }
 
+    public abstract void accept(IRepositoryVisitor visitor, int options);
 
-    public abstract void accept( IRepositoryVisitor visitor, int options );
-
-
-    public void addBundleRepositoryListener( IBundleRepositoryListener listener )
+    public void addBundleRepositoryListener(IBundleRepositoryListener listener)
     {
-        synchronized ( listeners )
+        synchronized (listeners)
         {
-            listeners.add( listener );
+            listeners.add(listener);
         }
     }
 
-
-    public void removeBundleRepositoryListener( IBundleRepositoryListener listener )
+    public void removeBundleRepositoryListener(IBundleRepositoryListener listener)
     {
-        synchronized ( listeners )
+        synchronized (listeners)
         {
-            listeners.remove( listener );
+            listeners.remove(listener);
         }
     }
 
-
     protected void notifyChange()
     {
-        for ( IBundleRepositoryListener l : listeners )
+        for (IBundleRepositoryListener l : listeners)
         {
-            l.notifyChange( this );
+            l.notifyChange(this);
         }
     }
 
-
     public String getId()
     {
         return id;
     }
 
-
-    public void accept( IRepositoryVisitor visitor )
+    public void accept(IRepositoryVisitor visitor)
     {
-        accept( visitor, 0 );
+        accept(visitor, 0);
     }
 
-
-    public void writeOBR( OutputStream out ) throws IOException
+    public void writeOBR(OutputStream out) throws IOException
     {
         throw new UnsupportedOperationException();
     }
 
-
-    public Collection<ISigilBundle> findProviders( final ILibrary library, int options )
+    public Collection<ISigilBundle> findProviders(final ILibrary library, int options)
     {
         final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
 
-        final ILicensePolicy policy = findPolicy( library );
+        final ILicensePolicy policy = findPolicy(library);
 
         IRepositoryVisitor visitor = new IRepositoryVisitor()
         {
-            public boolean visit( ISigilBundle bundle )
+            public boolean visit(ISigilBundle bundle)
             {
-                if ( policy.accept( bundle ) )
+                if (policy.accept(bundle))
                 {
                     IBundleModelElement info = bundle.getBundleInfo();
-                    for ( IPackageImport pi : library.getImports() )
+                    for (IPackageImport pi : library.getImports())
                     {
-                        for ( IPackageExport e : info.getExports() )
+                        for (IPackageExport e : info.getExports())
                         {
-                            if ( pi.getPackageName().equals( e.getPackageName() )
-                                && pi.getVersions().contains( e.getVersion() ) )
+                            if (pi.getPackageName().equals(e.getPackageName())
+                                && pi.getVersions().contains(e.getVersion()))
                             {
-                                found.add( bundle );
+                                found.add(bundle);
                                 break;
                             }
                         }
@@ -131,64 +120,63 @@
             }
         };
 
-        accept( visitor, options );
+        accept(visitor, options);
 
         return found;
     }
 
-
-    public Collection<ISigilBundle> findAllProviders( final IRequiredBundle req, int options )
+    public Collection<ISigilBundle> findAllProviders(final IRequiredBundle req,
+        int options)
     {
         final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
 
-        final ILicensePolicy policy = findPolicy( req );
+        final ILicensePolicy policy = findPolicy(req);
 
         IRepositoryVisitor visitor = new IRepositoryVisitor()
         {
-            public boolean visit( ISigilBundle bundle )
+            public boolean visit(ISigilBundle bundle)
             {
-                if ( policy.accept( bundle ) )
+                if (policy.accept(bundle))
                 {
                     IBundleModelElement info = bundle.getBundleInfo();
-                    if ( req.getSymbolicName().equals( info.getSymbolicName() )
-                        && req.getVersions().contains( info.getVersion() ) )
+                    if (req.getSymbolicName().equals(info.getSymbolicName())
+                        && req.getVersions().contains(info.getVersion()))
                     {
-                        found.add( bundle );
+                        found.add(bundle);
                     }
                 }
                 return true;
             }
         };
 
-        accept( visitor, options );
+        accept(visitor, options);
 
         return found;
     }
 
-
-    public Collection<ISigilBundle> findAllProviders( final IPackageImport pi, int options )
+    public Collection<ISigilBundle> findAllProviders(final IPackageImport pi, int options)
     {
         final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
 
-        final ILicensePolicy policy = findPolicy( pi );
+        final ILicensePolicy policy = findPolicy(pi);
 
         IRepositoryVisitor visitor = new IRepositoryVisitor()
         {
 
-            public boolean visit( ISigilBundle bundle )
+            public boolean visit(ISigilBundle bundle)
             {
-                if ( policy.accept( bundle ) )
+                if (policy.accept(bundle))
                 {
                     IBundleModelElement info = bundle.getBundleInfo();
-                    if ( info != null )
+                    if (info != null)
                     {
-                        for ( IPackageExport e : info.getExports() )
+                        for (IPackageExport e : info.getExports())
                         {
-                            if ( pi.getPackageName().equals( e.getPackageName() ) )
+                            if (pi.getPackageName().equals(e.getPackageName()))
                             {
-                                if ( pi.getVersions().contains( e.getVersion() ) )
+                                if (pi.getVersions().contains(e.getVersion()))
                                 {
-                                    found.add( bundle );
+                                    found.add(bundle);
                                     break;
                                 }
                             }
@@ -200,31 +188,30 @@
 
         };
 
-        accept( visitor, options );
+        accept(visitor, options);
 
         return found;
     }
 
-
-    public ISigilBundle findProvider( final IPackageImport pi, int options )
+    public ISigilBundle findProvider(final IPackageImport pi, int options)
     {
         final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
 
-        final ILicensePolicy policy = findPolicy( pi );
+        final ILicensePolicy policy = findPolicy(pi);
 
         IRepositoryVisitor visitor = new IRepositoryVisitor()
         {
-            public boolean visit( ISigilBundle bundle )
+            public boolean visit(ISigilBundle bundle)
             {
-                if ( policy.accept( bundle ) )
+                if (policy.accept(bundle))
                 {
                     IBundleModelElement info = bundle.getBundleInfo();
-                    for ( IPackageExport e : info.getExports() )
+                    for (IPackageExport e : info.getExports())
                     {
-                        if ( pi.getPackageName().equals( e.getPackageName() )
-                            && pi.getVersions().contains( e.getVersion() ) )
+                        if (pi.getPackageName().equals(e.getPackageName())
+                            && pi.getVersions().contains(e.getVersion()))
                         {
-                            found.add( bundle );
+                            found.add(bundle);
                             return false;
                         }
                     }
@@ -234,30 +221,29 @@
 
         };
 
-        accept( visitor, options );
+        accept(visitor, options);
 
         return found.isEmpty() ? null : found.iterator().next();
     }
 
-
-    public ISigilBundle findProvider( final IRequiredBundle req, int options )
+    public ISigilBundle findProvider(final IRequiredBundle req, int options)
     {
         final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
 
-        final ILicensePolicy policy = findPolicy( req );
+        final ILicensePolicy policy = findPolicy(req);
 
         IRepositoryVisitor visitor = new IRepositoryVisitor()
         {
 
-            public boolean visit( ISigilBundle bundle )
+            public boolean visit(ISigilBundle bundle)
             {
-                if ( policy.accept( bundle ) )
+                if (policy.accept(bundle))
                 {
                     IBundleModelElement info = bundle.getBundleInfo();
-                    if ( req.getSymbolicName().equals( info.getSymbolicName() )
-                        && req.getVersions().contains( info.getVersion() ) )
+                    if (req.getSymbolicName().equals(info.getSymbolicName())
+                        && req.getVersions().contains(info.getVersion()))
                     {
-                        found.add( bundle );
+                        found.add(bundle);
                         return false;
                     }
                 }
@@ -266,19 +252,17 @@
 
         };
 
-        accept( visitor, options );
+        accept(visitor, options);
 
         return found.isEmpty() ? null : found.iterator().next();
     }
 
-
-    public IBundleModelElement buildBundleModelElement( Manifest mf )
+    public IBundleModelElement buildBundleModelElement(Manifest mf)
     {
         return ManifestUtil.buildBundleModelElement(mf);
     }
 
-
-    protected ILicensePolicy findPolicy( IModelElement elem )
+    protected ILicensePolicy findPolicy(IModelElement elem)
     {
         ILicenseManager man = BldCore.getLicenseManager();
 
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractRepositoryManager.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractRepositoryManager.java
index 73cf4a0..f856bf1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractRepositoryManager.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractRepositoryManager.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -38,7 +37,6 @@
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.common.repository.RepositoryChangeEvent.Type;
 
-
 public abstract class AbstractRepositoryManager implements IRepositoryManager, IBundleRepositoryListener
 {
 
@@ -51,16 +49,15 @@
     private TreeMap<Integer, HashSet<IBundleRepository>> levelMap = new TreeMap<Integer, HashSet<IBundleRepository>>();
     private int[] levels;
 
-    private BundleResolver resolver = new BundleResolver( this );
+    private BundleResolver resolver = new BundleResolver(this);
 
     private ArrayList<ILibrary> libraries = new ArrayList<ILibrary>();
 
-
     public void initialise()
     {
-        synchronized ( repositories )
+        synchronized (repositories)
         {
-            if ( !initialised )
+            if (!initialised)
             {
                 initialised = true;
                 loadRepositories();
@@ -68,136 +65,126 @@
         }
     }
 
-
     protected abstract void loadRepositories();
 
-
-    public void addRepositoryChangeListener( IRepositoryChangeListener listener )
+    public void addRepositoryChangeListener(IRepositoryChangeListener listener)
     {
-        synchronized ( listeners )
+        synchronized (listeners)
         {
-            listeners.add( listener );
+            listeners.add(listener);
         }
     }
 
-
-    public void removeRepositoryChangeListener( IRepositoryChangeListener listener )
+    public void removeRepositoryChangeListener(IRepositoryChangeListener listener)
     {
-        synchronized ( listeners )
+        synchronized (listeners)
         {
-            listeners.remove( listener );
+            listeners.remove(listener);
         }
     }
 
-
-    public void notifyChange( IBundleRepository repository )
+    public void notifyChange(IBundleRepository repository)
     {
-        notifyListeners( new RepositoryChangeEvent( repository, Type.CHANGED ) );
+        notifyListeners(new RepositoryChangeEvent(repository, Type.CHANGED));
     }
 
-
-    private void notifyListeners( RepositoryChangeEvent event )
+    private void notifyListeners(RepositoryChangeEvent event)
     {
         ArrayList<IRepositoryChangeListener> safe = null;
-        synchronized ( listeners )
+        synchronized (listeners)
         {
-            safe = new ArrayList<IRepositoryChangeListener>( listeners );
+            safe = new ArrayList<IRepositoryChangeListener>(listeners);
         }
-        for ( IRepositoryChangeListener l : safe )
+        for (IRepositoryChangeListener l : safe)
         {
-            l.repositoryChanged( event );
+            l.repositoryChanged(event);
         }
     }
 
-
-    protected void setRepositories( IBundleRepository[] repos )
+    protected void setRepositories(IBundleRepository[] repos)
     {
-        synchronized ( repositories )
+        synchronized (repositories)
         {
             repositories.clear();
             order.clear();
             levelMap.clear();
             resetLevels();
-            if ( repos != null )
+            if (repos != null)
             {
-                for ( int i = 0; i < repos.length; i++ )
+                for (int i = 0; i < repos.length; i++)
                 {
-                    addRepository( repos[i], i );
+                    addRepository(repos[i], i);
                 }
             }
         }
     }
 
-
-    protected void addRepository( IBundleRepository rep, int level )
+    protected void addRepository(IBundleRepository rep, int level)
     {
         Type type = null;
 
-        synchronized ( repositories )
+        synchronized (repositories)
         {
-            IBundleRepository old = repositories.put( rep.getId(), rep );
-            if ( old == null )
+            IBundleRepository old = repositories.put(rep.getId(), rep);
+            if (old == null)
             {
                 type = Type.ADDED;
-                rep.addBundleRepositoryListener( this );
+                rep.addBundleRepositoryListener(this);
             }
             else
             {
-                old.removeBundleRepositoryListener( this );
+                old.removeBundleRepositoryListener(this);
                 type = Type.CHANGED;
-                order.remove( old );
-                clearLevel( rep );
+                order.remove(old);
+                clearLevel(rep);
             }
 
-            order.add( rep );
+            order.add(rep);
 
-            HashSet<IBundleRepository> set = levelMap.get( level );
+            HashSet<IBundleRepository> set = levelMap.get(level);
 
-            if ( set == null )
+            if (set == null)
             {
                 set = new HashSet<IBundleRepository>();
-                levelMap.put( level, set );
+                levelMap.put(level, set);
             }
 
-            set.add( rep );
+            set.add(rep);
             resetLevels();
         }
 
-        notifyListeners( new RepositoryChangeEvent( rep, type ) );
+        notifyListeners(new RepositoryChangeEvent(rep, type));
     }
 
-
-    protected void removeRepository( IBundleRepository rep )
+    protected void removeRepository(IBundleRepository rep)
     {
         Type type = null;
 
-        synchronized ( repositories )
+        synchronized (repositories)
         {
-            if ( repositories.remove( rep.getId() ) != null )
+            if (repositories.remove(rep.getId()) != null)
             {
-                order.remove( rep );
+                order.remove(rep);
                 type = Type.REMOVED;
-                clearLevel( rep );
+                clearLevel(rep);
                 resetLevels();
             }
         }
 
-        if ( type != null )
+        if (type != null)
         {
-            notifyListeners( new RepositoryChangeEvent( rep, type ) );
+            notifyListeners(new RepositoryChangeEvent(rep, type));
         }
     }
 
-
-    private void clearLevel( IBundleRepository rep )
+    private void clearLevel(IBundleRepository rep)
     {
-        for ( Iterator<Map.Entry<Integer, HashSet<IBundleRepository>>> iter = levelMap.entrySet().iterator(); iter
-            .hasNext(); )
+        for (Iterator<Map.Entry<Integer, HashSet<IBundleRepository>>> iter = levelMap.entrySet().iterator(); iter.hasNext();)
         {
             Map.Entry<Integer, HashSet<IBundleRepository>> e = iter.next();
-            if ( e.getValue().remove( rep ) )
+            if (e.getValue().remove(rep))
             {
-                if ( e.getValue().isEmpty() )
+                if (e.getValue().isEmpty())
                 {
                     iter.remove();
                 }
@@ -206,35 +193,33 @@
         }
     }
 
-
     public Collection<IBundleRepository> getRepositories()
     {
         initialise();
         ArrayList<IBundleRepository> safe = null;
 
-        synchronized ( repositories )
+        synchronized (repositories)
         {
-            safe = new ArrayList<IBundleRepository>( order );
+            safe = new ArrayList<IBundleRepository>(order);
         }
 
         return safe;
     }
 
-
     private void resetLevels()
     {
-        Collections.sort( order, new Comparator<IBundleRepository>()
+        Collections.sort(order, new Comparator<IBundleRepository>()
         {
-            public int compare( IBundleRepository o1, IBundleRepository o2 )
+            public int compare(IBundleRepository o1, IBundleRepository o2)
             {
-                int l1 = findLevel( o1 );
-                int l2 = findLevel( o2 );
+                int l1 = findLevel(o1);
+                int l2 = findLevel(o2);
 
-                if ( l1 < l2 )
+                if (l1 < l2)
                 {
                     return -1;
                 }
-                else if ( l1 > l2 )
+                else if (l1 > l2)
                 {
                     return 1;
                 }
@@ -244,90 +229,83 @@
                 }
             }
 
-
-            private int findLevel( IBundleRepository rep )
+            private int findLevel(IBundleRepository rep)
             {
-                for ( Map.Entry<Integer, HashSet<IBundleRepository>> e : levelMap.entrySet() )
+                for (Map.Entry<Integer, HashSet<IBundleRepository>> e : levelMap.entrySet())
                 {
-                    if ( e.getValue().contains( rep ) )
+                    if (e.getValue().contains(rep))
                     {
                         return e.getKey();
                     }
                 }
                 throw new IllegalStateException();
             }
-        } );
+        });
         levels = new int[levelMap.size()];
         int i = 0;
-        for ( Integer v : levelMap.keySet() )
+        for (Integer v : levelMap.keySet())
         {
             levels[i++] = v;
         }
     }
 
-
     public int[] getPriorityLevels()
     {
         initialise();
-        synchronized ( repositories )
+        synchronized (repositories)
         {
             return levels;
         }
     }
 
-
-    public Collection<IBundleRepository> getRepositories( int priorityLevel )
+    public Collection<IBundleRepository> getRepositories(int priorityLevel)
     {
         initialise();
         List<IBundleRepository> found = null;
 
-        synchronized ( repositories )
+        synchronized (repositories)
         {
-            HashSet<IBundleRepository> b = levelMap.get( priorityLevel );
-            if ( b == null )
+            HashSet<IBundleRepository> b = levelMap.get(priorityLevel);
+            if (b == null)
             {
                 found = Collections.emptyList();
             }
             else
             {
-                found = new ArrayList<IBundleRepository>( b );
+                found = new ArrayList<IBundleRepository>(b);
             }
         }
 
         return found;
     }
 
-
-    public void addLibrary( ILibrary library )
+    public void addLibrary(ILibrary library)
     {
-        synchronized ( libraries )
+        synchronized (libraries)
         {
-            libraries.add( library );
+            libraries.add(library);
         }
     }
 
-
-    public void removeLibrary( ILibrary library )
+    public void removeLibrary(ILibrary library)
     {
-        synchronized ( libraries )
+        synchronized (libraries)
         {
-            libraries.remove( library );
+            libraries.remove(library);
         }
     }
 
-
     public Collection<ILibrary> getLibraries()
     {
-        synchronized ( libraries )
+        synchronized (libraries)
         {
             return libraries;
         }
     }
 
-
-    public ILibrary resolveLibrary( final ILibraryImport l )
+    public ILibrary resolveLibrary(final ILibraryImport l)
     {
-        final ArrayList<ILibrary> found = new ArrayList<ILibrary>( 1 );
+        final ArrayList<ILibrary> found = new ArrayList<ILibrary>(1);
         //ISigilProjectModel p = l.getAncestor(ISigilProjectModel.class);
         //
         //IModelWalker w = new IModelWalker() {
@@ -344,63 +322,62 @@
         //p.visit( w );
 
         //if ( found.isEmpty() ) { // no project specific libraries - check workspace definitions
-        synchronized ( libraries )
+        synchronized (libraries)
         {
-            for ( ILibrary lib : libraries )
+            for (ILibrary lib : libraries)
             {
-                if ( l.getLibraryName().equals( lib.getName() ) && l.getVersions().contains( lib.getVersion() ) )
+                if (l.getLibraryName().equals(lib.getName())
+                    && l.getVersions().contains(lib.getVersion()))
                 {
-                    updateLibrary( l, lib, found );
+                    updateLibrary(l, lib, found);
                 }
             }
         }
         //}
 
-        return found.isEmpty() ? null : found.get( 0 );
+        return found.isEmpty() ? null : found.get(0);
     }
 
-
-    protected void updateLibrary( ILibraryImport li, ILibrary l, ArrayList<ILibrary> found )
+    protected void updateLibrary(ILibraryImport li, ILibrary l, ArrayList<ILibrary> found)
     {
-        if ( li.getLibraryName().equals( l.getName() ) && li.getVersions().contains( l.getVersion() ) )
+        if (li.getLibraryName().equals(l.getName())
+            && li.getVersions().contains(l.getVersion()))
         {
-            if ( found.isEmpty() )
+            if (found.isEmpty())
             {
-                found.add( l );
+                found.add(l);
             }
             else
             {
-                ILibrary c = found.get( 0 );
-                if ( l.getVersion().compareTo( c.getVersion() ) > 0 )
+                ILibrary c = found.get(0);
+                if (l.getVersion().compareTo(c.getVersion()) > 0)
                 {
-                    found.remove( 0 );
-                    found.add( l );
+                    found.remove(0);
+                    found.add(l);
                 }
             }
         }
     }
 
-
     public IBundleResolver getBundleResolver()
     {
         return resolver;
     }
 
-
-    public void visit( final IModelWalker walker )
+    public void visit(final IModelWalker walker)
     {
-        for ( IBundleRepository rep : getRepositories() )
+        for (IBundleRepository rep : getRepositories())
         {
             IRepositoryVisitor wrapper = new IRepositoryVisitor()
             {
-                public boolean visit( ISigilBundle bundle )
+                public boolean visit(ISigilBundle bundle)
                 {
-                    bundle.visit( walker );
+                    bundle.visit(walker);
                     // return true as still want to visit other bundles
                     return true;
                 }
             };
-            rep.accept( wrapper );
+            rep.accept(wrapper);
         }
     }
 }
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepository.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepository.java
index ed21a0b..227f662 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepository.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Collection;
@@ -29,46 +28,33 @@
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
 
-
 public interface IBundleRepository
 {
     static final int NORMAL_PRIORITY = 0;
     static final int MAXIMUM_PRIORITY = -500;
     static final int MINIMUM_PRIORITY = 500;
 
-
     String getId();
 
+    void addBundleRepositoryListener(IBundleRepositoryListener listener);
 
-    void addBundleRepositoryListener( IBundleRepositoryListener listener );
+    void removeBundleRepositoryListener(IBundleRepositoryListener listener);
 
+    void accept(IRepositoryVisitor visitor);
 
-    void removeBundleRepositoryListener( IBundleRepositoryListener listener );
+    void accept(IRepositoryVisitor visitor, int options);
 
-
-    void accept( IRepositoryVisitor visitor );
-
-
-    void accept( IRepositoryVisitor visitor, int options );
-
-
-    void writeOBR( OutputStream out ) throws IOException;
-
+    void writeOBR(OutputStream out) throws IOException;
 
     void refresh();
 
+    ISigilBundle findProvider(IPackageImport packageImport, int options);
 
-    ISigilBundle findProvider( IPackageImport packageImport, int options );
+    ISigilBundle findProvider(IRequiredBundle bundle, int options);
 
+    Collection<ISigilBundle> findAllProviders(IRequiredBundle bundle, int options);
 
-    ISigilBundle findProvider( IRequiredBundle bundle, int options );
+    Collection<ISigilBundle> findAllProviders(IPackageImport packageImport, int options);
 
-
-    Collection<ISigilBundle> findAllProviders( IRequiredBundle bundle, int options );
-
-
-    Collection<ISigilBundle> findAllProviders( IPackageImport packageImport, int options );
-
-
-    Collection<ISigilBundle> findProviders( ILibrary library, int options );
+    Collection<ISigilBundle> findProviders(ILibrary library, int options);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepositoryListener.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepositoryListener.java
index df7b208..b63bb5f 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepositoryListener.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepositoryListener.java
@@ -19,8 +19,7 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 public interface IBundleRepositoryListener
 {
-    void notifyChange( IBundleRepository repository );
+    void notifyChange(IBundleRepository repository);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleResolver.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleResolver.java
index 64a0492..c60d6b5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleResolver.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleResolver.java
@@ -19,12 +19,10 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import org.apache.felix.sigil.common.model.IModelElement;
 
-
 public interface IBundleResolver
 {
-    IResolution resolve( IModelElement element, ResolutionConfig config, IResolutionMonitor monitor )
-        throws ResolutionException;
+    IResolution resolve(IModelElement element, ResolutionConfig config,
+        IResolutionMonitor monitor) throws ResolutionException;
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IProviderChangeListener.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IProviderChangeListener.java
index 0f3e32f..38e313c 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IProviderChangeListener.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IProviderChangeListener.java
@@ -19,8 +19,7 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 public interface IProviderChangeListener
 {
-    void notifyChange( IRepositoryProvider provider );
+    void notifyChange(IRepositoryProvider provider);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryChangeListener.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryChangeListener.java
index e02445c..b70161d 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryChangeListener.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryChangeListener.java
@@ -19,8 +19,7 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 public interface IRepositoryChangeListener
 {
-    void repositoryChanged( RepositoryChangeEvent event );
+    void repositoryChanged(RepositoryChangeEvent event);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryManager.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryManager.java
index 496ef0f..53c2f69 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryManager.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryManager.java
@@ -19,45 +19,33 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import java.util.Collection;
 
 import org.apache.felix.sigil.common.model.IModelWalker;
 import org.apache.felix.sigil.common.model.eclipse.ILibrary;
 import org.apache.felix.sigil.common.model.eclipse.ILibraryImport;
 
-
 public interface IRepositoryManager
 {
-    void addRepositoryChangeListener( IRepositoryChangeListener listener );
+    void addRepositoryChangeListener(IRepositoryChangeListener listener);
 
-
-    void removeRepositoryChangeListener( IRepositoryChangeListener listener );
-
+    void removeRepositoryChangeListener(IRepositoryChangeListener listener);
 
     Collection<IBundleRepository> getRepositories();
 
+    Collection<IBundleRepository> getRepositories(int level);
 
-    Collection<IBundleRepository> getRepositories( int level );
+    void addLibrary(ILibrary library);
 
-
-    void addLibrary( ILibrary library );
-
-
-    void removeLibrary( ILibrary library );
-
+    void removeLibrary(ILibrary library);
 
     Collection<ILibrary> getLibraries();
 
-
-    ILibrary resolveLibrary( final ILibraryImport l );
-
+    ILibrary resolveLibrary(final ILibraryImport l);
 
     IBundleResolver getBundleResolver();
 
-
     int[] getPriorityLevels();
 
-
-    void visit( IModelWalker modelWalker );
+    void visit(IModelWalker modelWalker);
 }
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryProvider.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryProvider.java
index 394753d..dbc462e 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryProvider.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryProvider.java
@@ -19,11 +19,10 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import java.util.Properties;
 
-
 public interface IRepositoryProvider
 {
-    IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException;
+    IBundleRepository createRepository(String id, Properties properties)
+        throws RepositoryException;
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryVisitor.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryVisitor.java
index 22c86d2..0f59173 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryVisitor.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryVisitor.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 
-
 public interface IRepositoryVisitor
 {
     /**
@@ -31,5 +29,5 @@
      * @param bundle
      * @return
      */
-    boolean visit( ISigilBundle bundle );
+    boolean visit(ISigilBundle bundle);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolution.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolution.java
index edc07db..9a63899 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolution.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolution.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import java.util.List;
 import java.util.Set;
 
@@ -27,20 +26,15 @@
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 
-
 public interface IResolution
 {
     Set<ISigilBundle> getBundles();
 
+    ISigilBundle getProvider(IModelElement requirement);
 
-    ISigilBundle getProvider( IModelElement requirement );
+    List<IModelElement> getMatchedRequirements(ISigilBundle bundle);
 
-
-    List<IModelElement> getMatchedRequirements( ISigilBundle bundle );
-
-
-    void synchronize( IProgressMonitor monitor );
-
+    void synchronize(IProgressMonitor monitor);
 
     boolean isSynchronized();
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolutionMonitor.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolutionMonitor.java
index 8beaa34..a866611 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolutionMonitor.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolutionMonitor.java
@@ -19,18 +19,14 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 
-
 public interface IResolutionMonitor
 {
     boolean isCanceled();
 
+    void startResolution(IModelElement requirement);
 
-    void startResolution( IModelElement requirement );
-
-
-    void endResolution( IModelElement requirement, ISigilBundle sigilBundle );
+    void endResolution(IModelElement requirement, ISigilBundle sigilBundle);
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryChangeEvent.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryChangeEvent.java
index 7d1c2d8..d1be228 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryChangeEvent.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryChangeEvent.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 public class RepositoryChangeEvent
 {
     public static enum Type
@@ -30,20 +29,17 @@
     private Type type;
     private IBundleRepository repository;
 
-
-    public RepositoryChangeEvent( IBundleRepository repository, Type type )
+    public RepositoryChangeEvent(IBundleRepository repository, Type type)
     {
         this.repository = repository;
         this.type = type;
     }
 
-
     public Type getType()
     {
         return type;
     }
 
-
     public IBundleRepository getRepository()
     {
         return repository;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryException.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryException.java
index cfa4655..ccd39d3 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryException.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryException.java
@@ -19,28 +19,24 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 public class RepositoryException extends Exception
 {
 
     private static final long serialVersionUID = 1L;
 
-
-    public RepositoryException( String msg, Throwable cause )
+    public RepositoryException(String msg, Throwable cause)
     {
-        super( msg, cause );
+        super(msg, cause);
     }
 
-
-    public RepositoryException( String message )
+    public RepositoryException(String message)
     {
-        super( message );
+        super(message);
     }
 
-
-    public RepositoryException( Throwable cause )
+    public RepositoryException(Throwable cause)
     {
-        super( cause );
+        super(cause);
     }
 
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionConfig.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionConfig.java
index 275d0ae..35d6c2a 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionConfig.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionConfig.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 public class ResolutionConfig
 {
     private int options;
@@ -33,52 +32,44 @@
     public static final int LOCAL_ONLY = 16;
     public static final int COMPILE_TIME = 32;
 
-
     public ResolutionConfig()
     {
-        this( INCLUDE_DEPENDENTS );
+        this(INCLUDE_DEPENDENTS);
     }
 
-
-    public ResolutionConfig( int options )
+    public ResolutionConfig(int options)
     {
         this.options = options;
     }
 
-
     public int getOptions()
     {
         return options;
     }
 
-
     public boolean isDependents()
     {
-        return ( options & INCLUDE_DEPENDENTS ) != 0;
+        return (options & INCLUDE_DEPENDENTS) != 0;
     }
 
-
     public boolean isIgnoreErrors()
     {
-        return ( options & IGNORE_ERRORS ) != 0;
+        return (options & IGNORE_ERRORS) != 0;
     }
 
-
     public boolean isOptional()
     {
-        return ( options & INCLUDE_OPTIONAL ) != 0;
+        return (options & INCLUDE_OPTIONAL) != 0;
     }
 
-
     public boolean isCalculateLocalDependencies()
     {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     public boolean isCompileTime()
     {
-        return ( options & COMPILE_TIME ) != 0;
+        return (options & COMPILE_TIME) != 0;
     }
 }
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionException.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionException.java
index 1da491a..c68b9e1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionException.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionException.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import org.apache.felix.sigil.common.model.IModelElement;
 
-
 public class ResolutionException extends Exception
 {
 
@@ -30,48 +28,42 @@
 
     private IModelElement[] parsed;
 
-
-    public ResolutionException( String message, Throwable cause )
+    public ResolutionException(String message, Throwable cause)
     {
-        super( message, cause );
+        super(message, cause);
     }
 
-
-    public ResolutionException( String message )
+    public ResolutionException(String message)
     {
-        super( message );
+        super(message);
     }
 
-
-    public ResolutionException( Throwable cause )
+    public ResolutionException(Throwable cause)
     {
-        super( cause );
+        super(cause);
     }
 
-
-    public ResolutionException( IModelElement root, IModelElement[] parsed )
+    public ResolutionException(IModelElement root, IModelElement[] parsed)
     {
-        super( buildMessage( root, parsed ) );
+        super(buildMessage(root, parsed));
         this.parsed = parsed;
     }
 
-
-    private static String buildMessage( IModelElement root, IModelElement[] parsed )
+    private static String buildMessage(IModelElement root, IModelElement[] parsed)
     {
         StringBuilder b = new StringBuilder();
-        b.append( "Failed to resolve " );
-        b.append( root );
+        b.append("Failed to resolve ");
+        b.append(root);
 
-        if ( parsed.length > 0 )
+        if (parsed.length > 0)
         {
-            b.append( " due to missing provider for " );
-            b.append( parsed[parsed.length - 1] );
+            b.append(" due to missing provider for ");
+            b.append(parsed[parsed.length - 1]);
         }
 
         return b.toString();
     }
 
-
     public IModelElement[] getParsed()
     {
         return parsed;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionMonitorAdapter.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionMonitorAdapter.java
index f31dc91..9e5db18 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionMonitorAdapter.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionMonitorAdapter.java
@@ -19,39 +19,34 @@
 
 package org.apache.felix.sigil.common.repository;
 
-
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 
-
 public class ResolutionMonitorAdapter implements IResolutionMonitor
 {
 
     private IProgressMonitor monitor;
 
-
-    public ResolutionMonitorAdapter( IProgressMonitor monitor )
+    public ResolutionMonitorAdapter(IProgressMonitor monitor)
     {
         this.monitor = monitor;
     }
 
-
     public boolean isCanceled()
     {
         return monitor.isCanceled();
     }
 
-
-    public void startResolution( IModelElement requirement )
+    public void startResolution(IModelElement requirement)
     {
-        monitor.subTask( "Resolving " + requirement );
+        monitor.subTask("Resolving " + requirement);
     }
 
-
-    public void endResolution( IModelElement requirement, ISigilBundle provider )
+    public void endResolution(IModelElement requirement, ISigilBundle provider)
     {
-        monitor.subTask( ( provider == null ? "Failed to resolve " : "Resolved " ) + requirement );
+        monitor.subTask((provider == null ? "Failed to resolve " : "Resolved ")
+            + requirement);
     }
 
 }
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/AbstractSigilTestCase.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/AbstractSigilTestCase.java
index 60a0cb0..93453a0 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/AbstractSigilTestCase.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/AbstractSigilTestCase.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.junit;
 
-
 import java.lang.reflect.Method;
 import java.util.LinkedList;
 import java.util.List;
@@ -31,7 +30,6 @@
 
 import junit.framework.TestCase;
 
-
 public abstract class AbstractSigilTestCase extends TestCase
 {
 
@@ -39,91 +37,79 @@
 
     private BundleContext ctx;
 
-
-    public void setBundleContext( BundleContext ctx )
+    public void setBundleContext(BundleContext ctx)
     {
         this.ctx = ctx;
     }
 
-
     protected BundleContext getBundleContext()
     {
         return ctx;
     }
 
-
     @Override
     protected void setUp()
     {
-        for ( Class<?> c : getReferences() )
+        for (Class<?> c : getReferences())
         {
-            ServiceTracker t = createBindTracker( c );
+            ServiceTracker t = createBindTracker(c);
             t.open();
-            trackers.add( t );
+            trackers.add(t);
         }
     }
 
-
     @Override
     protected void tearDown()
     {
-        for ( ServiceTracker t : trackers )
+        for (ServiceTracker t : trackers)
         {
             t.close();
         }
         trackers.clear();
     }
 
-
-    private ServiceTracker createBindTracker( final Class<?> c )
+    private ServiceTracker createBindTracker(final Class<?> c)
     {
-        return new ServiceTracker( ctx, c.getName(), new ServiceTrackerCustomizer()
+        return new ServiceTracker(ctx, c.getName(), new ServiceTrackerCustomizer()
         {
-            public Object addingService( ServiceReference reference )
+            public Object addingService(ServiceReference reference)
             {
-                Object o = ctx.getService( reference );
-                Method m = getBindMethod( c );
-                if ( m != null )
-                    invoke( m, o );
+                Object o = ctx.getService(reference);
+                Method m = getBindMethod(c);
+                if (m != null)
+                    invoke(m, o);
                 return o;
             }
 
-
-            public void modifiedService( ServiceReference reference, Object service )
+            public void modifiedService(ServiceReference reference, Object service)
             {
             }
 
-
-            public void removedService( ServiceReference reference, Object service )
+            public void removedService(ServiceReference reference, Object service)
             {
-                Method m = getUnbindMethod( c );
-                if ( m != null )
-                    invoke( m, service );
-                ctx.ungetService( reference );
+                Method m = getUnbindMethod(c);
+                if (m != null)
+                    invoke(m, service);
+                ctx.ungetService(reference);
             }
-        } );
+        });
     }
 
-
-    private void invoke( Method m, Object o )
+    private void invoke(Method m, Object o)
     {
         try
         {
-            m.invoke( this, new Object[]
-                { o } );
+            m.invoke(this, new Object[] { o });
         }
-        catch ( Exception e )
+        catch (Exception e)
         {
-            throw new IllegalStateException( "Failed to invoke binding method " + m, e );
+            throw new IllegalStateException("Failed to invoke binding method " + m, e);
         }
     }
 
-
     protected abstract Class<?>[] getReferences();
 
+    protected abstract Method getBindMethod(Class<?> clazz);
 
-    protected abstract Method getBindMethod( Class<?> clazz );
-
-
-    protected abstract Method getUnbindMethod( Class<?> clazz );
+    protected abstract Method getUnbindMethod(Class<?> clazz);
 }
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/ReflectiveSigilTestCase.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/ReflectiveSigilTestCase.java
index 7d26a59..96743c3 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/ReflectiveSigilTestCase.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/ReflectiveSigilTestCase.java
@@ -19,13 +19,11 @@
 
 package org.apache.felix.sigil.common.junit;
 
-
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-
 public abstract class ReflectiveSigilTestCase extends AbstractSigilTestCase
 {
 
@@ -33,7 +31,6 @@
     private Map<Class<?>, Method> bindMethods;
     private Map<Class<?>, Method> unbindMethods;
 
-
     @Override
     protected Class<?>[] getReferences()
     {
@@ -41,75 +38,70 @@
         return references;
     }
 
-
     @Override
-    protected Method getBindMethod( Class<?> clazz )
+    protected Method getBindMethod(Class<?> clazz)
     {
-        return bindMethods.get( clazz );
+        return bindMethods.get(clazz);
     }
 
-
     @Override
-    protected Method getUnbindMethod( Class<?> clazz )
+    protected Method getUnbindMethod(Class<?> clazz)
     {
-        return unbindMethods.get( clazz );
+        return unbindMethods.get(clazz);
     }
 
-
     private void introspect()
     {
-        if ( references == null )
+        if (references == null)
         {
-            bindMethods = findBindMethods( getClass(), "set", "add" );
-            unbindMethods = findBindMethods( getClass(), "set", "remove" );
+            bindMethods = findBindMethods(getClass(), "set", "add");
+            unbindMethods = findBindMethods(getClass(), "set", "remove");
 
             HashSet<Class<?>> refs = new HashSet<Class<?>>();
-            refs.addAll( bindMethods.keySet() );
-            refs.addAll( unbindMethods.keySet() );
-            references = refs.toArray( new Class<?>[refs.size()] );
+            refs.addAll(bindMethods.keySet());
+            refs.addAll(unbindMethods.keySet());
+            references = refs.toArray(new Class<?>[refs.size()]);
         }
     }
 
-
-    private static Map<Class<?>, Method> findBindMethods( Class<?> clazz, String... prefix )
+    private static Map<Class<?>, Method> findBindMethods(Class<?> clazz, String... prefix)
     {
         HashMap<Class<?>, Method> found = new HashMap<Class<?>, Method>();
 
-        checkDeclaredMethods( clazz, found, prefix );
+        checkDeclaredMethods(clazz, found, prefix);
 
         return found;
     }
 
-
-    private static void checkDeclaredMethods( Class<?> clazz, Map<Class<?>, Method> found, String... prefix )
+    private static void checkDeclaredMethods(Class<?> clazz, Map<Class<?>, Method> found,
+        String... prefix)
     {
-        for ( Method m : clazz.getDeclaredMethods() )
+        for (Method m : clazz.getDeclaredMethods())
         {
-            if ( isMethodPrefixed( m, prefix ) && isBindSignature( m ) )
+            if (isMethodPrefixed(m, prefix) && isBindSignature(m))
             {
-                found.put( m.getParameterTypes()[0], m );
+                found.put(m.getParameterTypes()[0], m);
             }
         }
 
         Class<?> sup = clazz.getSuperclass();
-        if ( sup != null && sup != Object.class )
+        if (sup != null && sup != Object.class)
         {
-            checkDeclaredMethods( sup, found, prefix );
+            checkDeclaredMethods(sup, found, prefix);
         }
 
-        for ( Class<?> i : clazz.getInterfaces() )
+        for (Class<?> i : clazz.getInterfaces())
         {
-            checkDeclaredMethods( i, found, prefix );
+            checkDeclaredMethods(i, found, prefix);
         }
     }
 
-
-    private static boolean isMethodPrefixed( Method m, String... prefix )
+    private static boolean isMethodPrefixed(Method m, String... prefix)
     {
         String n = m.getName();
-        for ( String p : prefix )
+        for (String p : prefix)
         {
-            if ( n.startsWith( p ) && n.length() > p.length() )
+            if (n.startsWith(p) && n.length() > p.length())
             {
                 return true;
             }
@@ -117,8 +109,7 @@
         return false;
     }
 
-
-    private static boolean isBindSignature( Method m )
+    private static boolean isBindSignature(Method m)
     {
         return m.getReturnType() == Void.TYPE && m.getParameterTypes().length == 1;
     }
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/activator/Activator.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/activator/Activator.java
index 44ddc8b..a34511c 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/activator/Activator.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/activator/Activator.java
@@ -19,14 +19,12 @@
 
 package org.apache.felix.sigil.common.junit.activator;
 
-
 import org.apache.felix.sigil.common.junit.server.JUnitService;
 import org.apache.felix.sigil.common.junit.server.impl.JUnitServiceFactory;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
-
 /**
  * @author dave
  */
@@ -35,20 +33,18 @@
     private ServiceRegistration reg;
     private JUnitServiceFactory service;
 
-
-    public void start( final BundleContext ctx )
+    public void start(final BundleContext ctx)
     {
         service = new JUnitServiceFactory();
-        service.start( ctx );
-        reg = ctx.registerService( JUnitService.class.getName(), service, null );
+        service.start(ctx);
+        reg = ctx.registerService(JUnitService.class.getName(), service, null);
     }
 
-
-    public void stop( BundleContext ctx )
+    public void stop(BundleContext ctx)
     {
         reg.unregister();
         reg = null;
-        service.stop( ctx );
+        service.stop(ctx);
         service = null;
     }
 }
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/JUnitService.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/JUnitService.java
index ed3271f..0d73a50 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/JUnitService.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/JUnitService.java
@@ -19,21 +19,17 @@
 
 package org.apache.felix.sigil.common.junit.server;
 
-
 import java.util.Set;
 
 import org.osgi.framework.BundleContext;
 
 import junit.framework.TestSuite;
 
-
 public interface JUnitService
 {
     Set<String> getTests();
 
+    TestSuite createTest(String test);
 
-    TestSuite createTest( String test );
-
-
-    TestSuite createTest( String test, BundleContext ctx );
+    TestSuite createTest(String test, BundleContext ctx);
 }
\ No newline at end of file
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceFactory.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceFactory.java
index 6af3f6c..838d30a 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceFactory.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceFactory.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.junit.server.impl;
 
-
 import java.util.HashMap;
 import java.util.Set;
 import java.util.TreeSet;
@@ -32,69 +31,60 @@
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 
-
 public class JUnitServiceFactory implements ServiceFactory
 {
 
     private HashMap<String, Class<? extends TestCase>> tests = new HashMap<String, Class<? extends TestCase>>();
     private TestClassListener listener;
 
-
-    public void start( BundleContext ctx )
+    public void start(BundleContext ctx)
     {
-        listener = new TestClassListener( this );
-        ctx.addBundleListener( listener );
+        listener = new TestClassListener(this);
+        ctx.addBundleListener(listener);
         //listener.index(ctx.getBundle());
-        for ( Bundle b : ctx.getBundles() )
+        for (Bundle b : ctx.getBundles())
         {
-            if ( b.getState() == Bundle.RESOLVED )
+            if (b.getState() == Bundle.RESOLVED)
             {
-                listener.index( b );
+                listener.index(b);
             }
         }
     }
 
-
-    public void stop( BundleContext ctx )
+    public void stop(BundleContext ctx)
     {
-        ctx.removeBundleListener( listener );
+        ctx.removeBundleListener(listener);
         listener = null;
     }
 
-
-    public Object getService( Bundle bundle, ServiceRegistration reg )
+    public Object getService(Bundle bundle, ServiceRegistration reg)
     {
-        return new JUnitServiceImpl( this, bundle.getBundleContext() );
+        return new JUnitServiceImpl(this, bundle.getBundleContext());
     }
 
-
-    public void ungetService( Bundle bundle, ServiceRegistration reg, Object service )
+    public void ungetService(Bundle bundle, ServiceRegistration reg, Object service)
     {
     }
 
-
-    public void registerTest( Class<? extends TestCase> clazz )
+    public void registerTest(Class<? extends TestCase> clazz)
     {
-        tests.put( clazz.getName(), clazz );
+        tests.put(clazz.getName(), clazz);
     }
 
-
-    public void unregister( Class<? extends TestCase> clazz )
+    public void unregister(Class<? extends TestCase> clazz)
     {
-        tests.remove( clazz.getName() );
+        tests.remove(clazz.getName());
     }
 
-
     public Set<String> getTests()
     {
-        return new TreeSet<String>( tests.keySet() );
+        return new TreeSet<String>(tests.keySet());
     }
 
-
-    public TestSuite getTest( String test )
+    public TestSuite getTest(String test)
     {
-        Class<? extends TestCase> tc = tests.get( test );
-        return tc == null ? null : new TestSuite( tc );
+        Class<? extends TestCase> tc = tests.get(test);
+        return tc == null ? null : new TestSuite(tc);
     }
 
 }
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceImpl.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceImpl.java
index d9b5cfa..593d280 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceImpl.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceImpl.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.junit.server.impl;
 
-
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Arrays;
@@ -35,156 +34,147 @@
 import org.apache.felix.sigil.common.junit.server.JUnitService;
 import org.osgi.framework.BundleContext;
 
-
 public class JUnitServiceImpl implements JUnitService
 {
 
-    private static final Logger log = Logger.getLogger( JUnitServiceImpl.class.getName() );
+    private static final Logger log = Logger.getLogger(JUnitServiceImpl.class.getName());
 
-    private static final Class<?>[] BUNDLE_CONTEXT_PARAMS = new Class[]
-        { BundleContext.class };
+    private static final Class<?>[] BUNDLE_CONTEXT_PARAMS = new Class[] { BundleContext.class };
 
     private final JUnitServiceFactory junitServiceFactory;
     private final BundleContext bundleContext;
 
-
-    public JUnitServiceImpl( JUnitServiceFactory junitServiceFactory, BundleContext bundleContext )
+    public JUnitServiceImpl(JUnitServiceFactory junitServiceFactory, BundleContext bundleContext)
     {
         this.junitServiceFactory = junitServiceFactory;
         this.bundleContext = bundleContext;
     }
 
-
     public Set<String> getTests()
     {
         return junitServiceFactory.getTests();
     }
 
-
-    public TestSuite createTest( String test )
+    public TestSuite createTest(String test)
     {
-        return createTest( test, null );
+        return createTest(test, null);
     }
 
-
-    public TestSuite createTest( String test, BundleContext ctx )
+    public TestSuite createTest(String test, BundleContext ctx)
     {
         try
         {
-            TestSuite ts = junitServiceFactory.getTest( test );
+            TestSuite ts = junitServiceFactory.getTest(test);
 
-            if ( ts == null )
+            if (ts == null)
                 return null;
 
-            TestSuite ret = new TestSuite( ts.getName() );
+            TestSuite ret = new TestSuite(ts.getName());
 
             Enumeration<Test> e = ts.tests();
 
-            while ( e.hasMoreElements() )
+            while (e.hasMoreElements())
             {
                 Test t = e.nextElement();
-                setContext( t, ctx );
-                ret.addTest( t );
+                setContext(t, ctx);
+                ret.addTest(t);
             }
 
             return ret;
         }
-        catch ( final NoClassDefFoundError e )
+        catch (final NoClassDefFoundError e)
         {
-            TestSuite s = new TestSuite( test );
-            s.addTest( new Test()
+            TestSuite s = new TestSuite(test);
+            s.addTest(new Test()
             {
                 public int countTestCases()
                 {
                     return 1;
                 }
 
-
-                public void run( TestResult result )
+                public void run(TestResult result)
                 {
-                    result.addError( this, e );
+                    result.addError(this, e);
                 }
-            } );
+            });
             return s;
         }
-        catch ( final RuntimeException e )
+        catch (final RuntimeException e)
         {
-            TestSuite s = new TestSuite( test );
-            s.addTest( new Test()
+            TestSuite s = new TestSuite(test);
+            s.addTest(new Test()
             {
                 public int countTestCases()
                 {
                     return 1;
                 }
 
-
-                public void run( TestResult result )
+                public void run(TestResult result)
                 {
-                    result.addError( this, e );
+                    result.addError(this, e);
                 }
 
-            } );
+            });
             return s;
         }
     }
 
-
-    private void setContext( Test t, BundleContext ctx )
+    private void setContext(Test t, BundleContext ctx)
     {
         try
         {
-            Method m = findMethod( t.getClass(), "setBundleContext", BUNDLE_CONTEXT_PARAMS );
-            if ( m != null )
-                m.invoke( t, ctx == null ? bundleContext : ctx );
+            Method m = findMethod(t.getClass(), "setBundleContext", BUNDLE_CONTEXT_PARAMS);
+            if (m != null)
+                m.invoke(t, ctx == null ? bundleContext : ctx);
         }
-        catch ( SecurityException e )
+        catch (SecurityException e)
         {
-            log.log( Level.WARNING, "Failed to set bundle context on " + t, e );
+            log.log(Level.WARNING, "Failed to set bundle context on " + t, e);
         }
-        catch ( IllegalArgumentException e )
+        catch (IllegalArgumentException e)
         {
-            log.log( Level.WARNING, "Failed to set bundle context on " + t, e );
+            log.log(Level.WARNING, "Failed to set bundle context on " + t, e);
         }
-        catch ( IllegalAccessException e )
+        catch (IllegalAccessException e)
         {
-            log.log( Level.WARNING, "Failed to set bundle context on " + t, e );
+            log.log(Level.WARNING, "Failed to set bundle context on " + t, e);
         }
-        catch ( InvocationTargetException e )
+        catch (InvocationTargetException e)
         {
-            log.log( Level.WARNING, "Failed to set bundle context on " + t, e );
+            log.log(Level.WARNING, "Failed to set bundle context on " + t, e);
         }
     }
 
-
-    private Method findMethod( Class<?> clazz, String name, Class<?>[] params )
+    private Method findMethod(Class<?> clazz, String name, Class<?>[] params)
     {
         Method found = null;
 
-        for ( Method m : clazz.getDeclaredMethods() )
+        for (Method m : clazz.getDeclaredMethods())
         {
-            if ( m.getName().equals( name ) && Arrays.deepEquals( m.getParameterTypes(), params ) )
+            if (m.getName().equals(name)
+                && Arrays.deepEquals(m.getParameterTypes(), params))
             {
                 found = m;
                 break;
             }
         }
 
-        if ( found == null )
+        if (found == null)
         {
             Class<?> c = clazz.getSuperclass();
 
-            if ( c != null && c != Object.class )
+            if (c != null && c != Object.class)
             {
-                found = findMethod( c, name, params );
+                found = findMethod(c, name, params);
             }
         }
 
-        if ( found == null )
+        if (found == null)
         {
-            for ( Class<?> c : clazz.getInterfaces() )
+            for (Class<?> c : clazz.getInterfaces())
             {
-                found = findMethod( c, name, params );
-                if ( found != null )
+                found = findMethod(c, name, params);
+                if (found != null)
                 {
                     break;
                 }
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/TestClassListener.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/TestClassListener.java
index d3ee7a3..3c7b22b 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/TestClassListener.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/TestClassListener.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.junit.server.impl;
 
-
 import java.lang.reflect.Modifier;
 import java.net.URL;
 import java.util.Enumeration;
@@ -35,136 +34,127 @@
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.SynchronousBundleListener;
 
-
 public class TestClassListener implements SynchronousBundleListener
 {
-    private static final Logger log = Logger.getLogger( TestClassListener.class.getName() );
+    private static final Logger log = Logger.getLogger(TestClassListener.class.getName());
 
     private final JUnitServiceFactory service;
 
     private HashMap<Long, Class<TestCase>[]> registrations = new HashMap<Long, Class<TestCase>[]>();
 
-
-    public TestClassListener( JUnitServiceFactory service )
+    public TestClassListener(JUnitServiceFactory service)
     {
         this.service = service;
     }
 
-
-    public void bundleChanged( BundleEvent event )
+    public void bundleChanged(BundleEvent event)
     {
-        switch ( event.getType() )
+        switch (event.getType())
         {
             case BundleEvent.RESOLVED:
-                index( event.getBundle() );
+                index(event.getBundle());
                 break;
             case BundleEvent.UNRESOLVED:
-                unindex( event.getBundle() );
+                unindex(event.getBundle());
                 break;
         }
     }
 
-
-    void index( Bundle bundle )
+    void index(Bundle bundle)
     {
-        if ( isTestBundle( bundle ) )
+        if (isTestBundle(bundle))
         {
-            List<String> tests = findTests( bundle );
+            List<String> tests = findTests(bundle);
 
-            if ( !tests.isEmpty() )
+            if (!tests.isEmpty())
             {
                 LinkedList<Class<? extends TestCase>> regs = new LinkedList<Class<? extends TestCase>>();
 
-                for ( String jc : tests )
+                for (String jc : tests)
                 {
                     try
                     {
-                        Class<?> clazz = bundle.loadClass( jc );
-                        if ( isTestCase( clazz ) )
+                        Class<?> clazz = bundle.loadClass(jc);
+                        if (isTestCase(clazz))
                         {
-                            Class<? extends TestCase> tc = clazz.asSubclass( TestCase.class );
-                            regs.add( tc );
-                            service.registerTest( tc );
+                            Class<? extends TestCase> tc = clazz.asSubclass(TestCase.class);
+                            regs.add(tc);
+                            service.registerTest(tc);
                         }
                     }
-                    catch ( ClassNotFoundException e )
+                    catch (ClassNotFoundException e)
                     {
-                        log.log( Level.WARNING, "Failed to load class " + jc, e );
+                        log.log(Level.WARNING, "Failed to load class " + jc, e);
                     }
-                    catch ( NoClassDefFoundError e )
+                    catch (NoClassDefFoundError e)
                     {
-                        log.log( Level.WARNING, "Failed to load class " + jc, e );
+                        log.log(Level.WARNING, "Failed to load class " + jc, e);
                     }
                 }
 
-                registrations.put( bundle.getBundleId(), toArray( regs ) );
+                registrations.put(bundle.getBundleId(), toArray(regs));
             }
         }
     }
 
-
-    private boolean isTestBundle( Bundle bundle )
+    private boolean isTestBundle(Bundle bundle)
     {
         try
         {
-            bundle.loadClass( TestCase.class.getName() );
+            bundle.loadClass(TestCase.class.getName());
             return true;
         }
-        catch ( ClassNotFoundException e )
+        catch (ClassNotFoundException e)
         {
             return false;
         }
     }
 
-
     @SuppressWarnings("unchecked")
-    private Class<TestCase>[] toArray( LinkedList<Class<? extends TestCase>> regs )
+    private Class<TestCase>[] toArray(LinkedList<Class<? extends TestCase>> regs)
     {
-        return regs.toArray( new Class[regs.size()] );
+        return regs.toArray(new Class[regs.size()]);
     }
 
-
-    private boolean isTestCase( Class<?> clazz )
+    private boolean isTestCase(Class<?> clazz)
     {
-        return TestCase.class.isAssignableFrom( clazz ) && !Modifier.isAbstract( clazz.getModifiers() )
-            && !clazz.getPackage().getName().startsWith( "junit" );
+        return TestCase.class.isAssignableFrom(clazz)
+            && !Modifier.isAbstract(clazz.getModifiers())
+            && !clazz.getPackage().getName().startsWith("junit");
     }
 
-
-    void unindex( Bundle bundle )
+    void unindex(Bundle bundle)
     {
-        Class<TestCase>[] classes = registrations.remove( bundle.getBundleId() );
-        if ( classes != null )
+        Class<TestCase>[] classes = registrations.remove(bundle.getBundleId());
+        if (classes != null)
         {
-            for ( Class<TestCase> tc : classes )
+            for (Class<TestCase> tc : classes)
             {
-                service.unregister( tc );
+                service.unregister(tc);
             }
         }
     }
 
-
-    private List<String> findTests( Bundle bundle )
+    private List<String> findTests(Bundle bundle)
     {
         @SuppressWarnings("unchecked")
-        Enumeration<URL> urls = bundle.findEntries( "", "*.class", true );
+        Enumeration<URL> urls = bundle.findEntries("", "*.class", true);
 
         LinkedList<String> tests = new LinkedList<String>();
-        while ( urls.hasMoreElements() )
+        while (urls.hasMoreElements())
         {
             URL url = urls.nextElement();
-            tests.add( toClassName( url ) );
+            tests.add(toClassName(url));
         }
 
         return tests;
     }
 
-
-    private String toClassName( URL url )
+    private String toClassName(URL url)
     {
         String f = url.getFile();
-        String cn = f.substring( 1, f.length() - 6 );
-        return cn.replace( '/', '.' );
+        String cn = f.substring(1, f.length() - 6);
+        return cn.replace('/', '.');
     }
 
 }
diff --git a/sigil/common/obr.test/src/org/apache/felix/sigil/obr/impl/VersionRangeHelperTest.java b/sigil/common/obr.test/src/org/apache/felix/sigil/obr/impl/VersionRangeHelperTest.java
index 840d2b3..75a7513 100644
--- a/sigil/common/obr.test/src/org/apache/felix/sigil/obr/impl/VersionRangeHelperTest.java
+++ b/sigil/common/obr.test/src/org/apache/felix/sigil/obr/impl/VersionRangeHelperTest.java
@@ -29,120 +29,136 @@
 
 public class VersionRangeHelperTest extends TestCase
 {
-    public void testRange1() {
+    public void testRange1()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
-        expr = LDAPParser.parseExpression("(&(version>=1.0.0)(version<=2.0.0))" );
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("[1.0.0,2.0.0]"), range );
+
+        expr = LDAPParser.parseExpression("(&(version>=1.0.0)(version<=2.0.0))");
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("[1.0.0,2.0.0]"), range);
     }
-    
-    public void testRange2() {
+
+    public void testRange2()
+    {
         LDAPExpr expr;
         VersionRange range;
-            
+
         expr = LDAPParser.parseExpression("(&(version>1.0.0)(version<2.0.0))");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("(1.0.0,2.0.0)"), range );        
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("(1.0.0,2.0.0)"), range);
     }
-    
-    public void testRange3() {
+
+    public void testRange3()
+    {
         LDAPExpr expr;
         VersionRange range;
 
         expr = LDAPParser.parseExpression("(&(!(version<1.0.0))(!(version>2.0.0)))");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("[1.0.0,2.0.0]"), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("[1.0.0,2.0.0]"), range);
     }
-    
-    public void testRange4() {
+
+    public void testRange4()
+    {
         LDAPExpr expr;
         VersionRange range;
 
         expr = LDAPParser.parseExpression("(&(!(version<=1.0.0))(!(version>=2.0.0)))");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("(1.0.0,2.0.0)"), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("(1.0.0,2.0.0)"), range);
     }
-    
-    public void testRange5() {
+
+    public void testRange5()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(version=1.0.0)");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("[1.0.0,1.0.0]"), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("[1.0.0,1.0.0]"), range);
     }
-    
-    public void testRange6() {
+
+    public void testRange6()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(version>=1.0.0)");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( new VersionRange(false, new Version(1,0,0), VersionRange.INFINITE_VERSION, true ), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(new VersionRange(false, new Version(1, 0, 0),
+            VersionRange.INFINITE_VERSION, true), range);
     }
-    
-    public void testRange7() {
+
+    public void testRange7()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(version<=2.0.0)");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("[0,2.0.0]"), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("[0,2.0.0]"), range);
     }
-    
-    public void testRange8() {
+
+    public void testRange8()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(version>1.0.0)");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( new VersionRange(true, new Version(1,0,0), VersionRange.INFINITE_VERSION, true ), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(new VersionRange(true, new Version(1, 0, 0),
+            VersionRange.INFINITE_VERSION, true), range);
     }
-    
-    public void testRange9() {
+
+    public void testRange9()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(version<2.0.0)");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("[0,2.0.0)"), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("[0,2.0.0)"), range);
     }
-    
-    public void testRange10() {
+
+    public void testRange10()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(!(version>2.0.0))");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("[0,2.0.0]"), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("[0,2.0.0]"), range);
     }
-    
-    public void testRange11() {
+
+    public void testRange11()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(!(version<1.0.0))");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("1.0.0"), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("1.0.0"), range);
     }
-    
-    public void testRange12() {
+
+    public void testRange12()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(!(version>=2.0.0))");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( VersionRange.parseVersionRange("[0,2.0.0)"), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(VersionRange.parseVersionRange("[0,2.0.0)"), range);
     }
-    
-    public void testRange13() {
+
+    public void testRange13()
+    {
         LDAPExpr expr;
         VersionRange range;
-        
+
         expr = LDAPParser.parseExpression("(!(version<=1.0.0))");
-        range = VersionRangeHelper.decodeVersions( expr );
-        assertEquals( new VersionRange(true, new Version(1,0,0), VersionRange.INFINITE_VERSION, true ), range );
+        range = VersionRangeHelper.decodeVersions(expr);
+        assertEquals(new VersionRange(true, new Version(1, 0, 0),
+            VersionRange.INFINITE_VERSION, true), range);
     }
 }
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
index 37deb2d..c073afc 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
@@ -49,13 +49,15 @@
         try
         {
             File urlFile = new File(urlStr);
-            URL repositoryURL = urlFile.exists() ? urlFile.toURI().toURL() : new URL(urlStr);
+            URL repositoryURL = urlFile.exists() ? urlFile.toURI().toURL() : new URL(
+                urlStr);
             URL testURL = urlFile.exists() ? urlFile.toURI().toURL() : new URL(urlStr);
             File indexCache = new File(preferences.getProperty(INDEX_CACHE_FILE));
             File localCache = new File(preferences.getProperty(CACHE_DIRECTORY));
             String auth = preferences.getProperty(AUTH_FILE);
             File authFile = auth == null ? null : new File(auth);
-            Long up = preferences.containsKey(UPDATE_PERIOD) ? Long.parseLong( preferences.getProperty(UPDATE_PERIOD) ) : 60 * 60 * 24 * 7; 
+            Long up = preferences.containsKey(UPDATE_PERIOD) ? Long.parseLong(preferences.getProperty(UPDATE_PERIOD))
+                : 60 * 60 * 24 * 7;
 
             if (testURL.openConnection().getLastModified() == 0)
             {
@@ -65,7 +67,7 @@
                 System.err.println("WARNING: " + msg + "using cache: " + urlStr);
             }
 
-            long updatePeriod = TimeUnit.MILLISECONDS.convert(up,TimeUnit.SECONDS);
+            long updatePeriod = TimeUnit.MILLISECONDS.convert(up, TimeUnit.SECONDS);
             if (preferences.getProperty(IN_MEMORY) == null)
             {
                 return new NonCachingOBRBundleRepository(id, repositoryURL, indexCache,
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRHandler.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRHandler.java
index fa52e42..17757b2 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRHandler.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRHandler.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.obr.impl;
 
-
 import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -49,7 +48,6 @@
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
-
 final class OBRHandler extends DefaultHandler
 {
     private static final String PACKAGE = "package";
@@ -67,175 +65,178 @@
     private IPackageExport export;
     private int depth;
 
-
-    public OBRHandler( URL obrURL, File bundleCache, OBRListener listener )
+    public OBRHandler(URL obrURL, File bundleCache, OBRListener listener)
     {
         this.obrURL = obrURL;
         this.cacheDir = bundleCache;
         this.listener = listener;
     }
 
-
-    public void setDocumentLocator( Locator locator )
+    public void setDocumentLocator(Locator locator)
     {
         this.locator = locator;
     }
 
-
-    public void startElement( String uri, String localName, String qName, Attributes attributes ) throws SAXException
+    public void startElement(String uri, String localName, String qName,
+        Attributes attributes) throws SAXException
     {
-        if ( depth++ == 0 && !"repository".equals( qName ) ) {
-            throw new SAXParseException("Invalid OBR document, expected repository top level element", locator);
-        }
-        else if ( "resource".equals( qName ) )
+        if (depth++ == 0 && !"repository".equals(qName))
         {
-            startResource( attributes );
+            throw new SAXParseException(
+                "Invalid OBR document, expected repository top level element", locator);
         }
-        else if ( "capability".equals( qName ) )
+        else if ("resource".equals(qName))
         {
-            startCapability( attributes );
+            startResource(attributes);
         }
-        else if ( "require".equals( qName ) )
+        else if ("capability".equals(qName))
         {
-            startRequire( attributes );
+            startCapability(attributes);
         }
-        else if ( "p".equals( qName ) )
+        else if ("require".equals(qName))
         {
-            startProperty( attributes );
+            startRequire(attributes);
+        }
+        else if ("p".equals(qName))
+        {
+            startProperty(attributes);
         }
     }
 
-
-    public void endElement( String uri, String localName, String qName ) throws SAXException
+    public void endElement(String uri, String localName, String qName)
+        throws SAXException
     {
         depth--;
-        if ( "resource".equals( qName ) )
+        if ("resource".equals(qName))
         {
             endResource();
         }
-        else if ( "capability".equals( qName ) )
+        else if ("capability".equals(qName))
         {
             endCapability();
         }
-        else if ( "require".equals( qName ) )
+        else if ("require".equals(qName))
         {
             endRequire();
         }
-        else if ( "p".equals( qName ) )
+        else if ("p".equals(qName))
         {
             endProperty();
         }
     }
 
-
-    private void startResource( Attributes attributes ) throws SAXException
+    private void startResource(Attributes attributes) throws SAXException
     {
         try
         {
-            String uri = attributes.getValue( "", URI );
-            if ( uri.endsWith( ".jar" ) )
+            String uri = attributes.getValue("", URI);
+            if (uri.endsWith(".jar"))
             {
-                if ( !sanity.add( uri ) )
+                if (!sanity.add(uri))
                 {
-                    throw new RuntimeException( uri );
+                    throw new RuntimeException(uri);
                 }
-                ISigilBundle b = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
-                IBundleModelElement info = ModelElementFactory.getInstance()
-                    .newModelElement( IBundleModelElement.class );
-                info.setSymbolicName( attributes.getValue( "", SYMBOLIC_NAME ) );
-                info.setVersion( VersionTable.getVersion(attributes.getValue( "", VERSION ) ) );
-                info.setName( attributes.getValue( "", PRESENTATION_NAME ) );
-                URI l = makeAbsolute( uri );
-                info.setUpdateLocation( l );
-                if ( "file".equals(  l.getScheme() ) ) {
-                    b.setLocation( new File( l ) );
+                ISigilBundle b = ModelElementFactory.getInstance().newModelElement(
+                    ISigilBundle.class);
+                IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(
+                    IBundleModelElement.class);
+                info.setSymbolicName(attributes.getValue("", SYMBOLIC_NAME));
+                info.setVersion(VersionTable.getVersion(attributes.getValue("", VERSION)));
+                info.setName(attributes.getValue("", PRESENTATION_NAME));
+                URI l = makeAbsolute(uri);
+                info.setUpdateLocation(l);
+                if ("file".equals(l.getScheme()))
+                {
+                    b.setLocation(new File(l));
                 }
-                else {
-                    b.setLocation( cachePath( info ) );
+                else
+                {
+                    b.setLocation(cachePath(info));
                 }
-                b.setBundleInfo( info );
+                b.setBundleInfo(info);
                 bundle = b;
             }
         }
-        catch ( Exception e )
+        catch (Exception e)
         {
-            throw new SAXParseException( "Failed to build bundle info", locator, e );
+            throw new SAXParseException("Failed to build bundle info", locator, e);
         }
     }
 
-
-    private URI makeAbsolute( String uri ) throws URISyntaxException
+    private URI makeAbsolute(String uri) throws URISyntaxException
     {
-        URI l = new URI( uri );
-        if ( !l.isAbsolute() )
+        URI l = new URI(uri);
+        if (!l.isAbsolute())
         {
             String base = obrURL.toExternalForm();
-            int i = base.lastIndexOf( "/" );
-            if ( i != -1 )
+            int i = base.lastIndexOf("/");
+            if (i != -1)
             {
-                base = base.substring( 0, i );
-                l = new URI( base + ( uri.startsWith( "/" ) ? "" : "/" ) + uri );
+                base = base.substring(0, i);
+                l = new URI(base + (uri.startsWith("/") ? "" : "/") + uri);
             }
         }
         return l;
     }
 
-
-    private File cachePath( IBundleModelElement info )
+    private File cachePath(IBundleModelElement info)
     {
-        return new File( cacheDir, info.getSymbolicName() + "_" + info.getVersion() + ".jar" );
+        return new File(cacheDir, info.getSymbolicName() + "_" + info.getVersion()
+            + ".jar");
     }
 
-
-    private void startCapability( Attributes attributes )
+    private void startCapability(Attributes attributes)
     {
-        if ( bundle != null )
+        if (bundle != null)
         {
-            if ( PACKAGE.equals( attributes.getValue( "", "name" ) ) )
+            if (PACKAGE.equals(attributes.getValue("", "name")))
             {
-                export = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
+                export = ModelElementFactory.getInstance().newModelElement(
+                    IPackageExport.class);
             }
         }
     }
 
-
-    private void startRequire( Attributes attributes ) throws SAXParseException
+    private void startRequire(Attributes attributes) throws SAXParseException
     {
-        if ( bundle != null )
+        if (bundle != null)
         {
-            String name = attributes.getValue( "name" );
-            if ( PACKAGE.equals( name ) )
+            String name = attributes.getValue("name");
+            if (PACKAGE.equals(name))
             {
-                IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
+                IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+                    IPackageImport.class);
                 try
                 {
-                    LDAPExpr expr = LDAPParser.parseExpression( attributes.getValue( "filter" ) );
-                    pi.setPackageName( decodePackage( expr, locator ) );
-                    pi.setVersions( decodeVersions( expr, locator ) );
-                    pi.setOptional( Boolean.valueOf( attributes.getValue( "optional" ) ) );
-                    bundle.getBundleInfo().addImport( pi );
+                    LDAPExpr expr = LDAPParser.parseExpression(attributes.getValue("filter"));
+                    pi.setPackageName(decodePackage(expr, locator));
+                    pi.setVersions(decodeVersions(expr, locator));
+                    pi.setOptional(Boolean.valueOf(attributes.getValue("optional")));
+                    bundle.getBundleInfo().addImport(pi);
                 }
-                catch ( LDAPParseException e )
+                catch (LDAPParseException e)
                 {
-                    throw new SAXParseException( "Failed to parse filter", locator, e );
+                    throw new SAXParseException("Failed to parse filter", locator, e);
                 }
             }
-            else if ( "bundle".equals( name ) )
+            else if ("bundle".equals(name))
             {
-                IRequiredBundle b = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
+                IRequiredBundle b = ModelElementFactory.getInstance().newModelElement(
+                    IRequiredBundle.class);
                 try
                 {
-                    LDAPExpr expr = LDAPParser.parseExpression( attributes.getValue( "filter" ) );
-                    b.setSymbolicName( decodeSymbolicName( expr, locator ) );
-                    b.setVersions( decodeVersions( expr, locator ) );
-                    b.setOptional( Boolean.valueOf( attributes.getValue( "optional" ) ) );
-                    bundle.getBundleInfo().addRequiredBundle( b );
+                    LDAPExpr expr = LDAPParser.parseExpression(attributes.getValue("filter"));
+                    b.setSymbolicName(decodeSymbolicName(expr, locator));
+                    b.setVersions(decodeVersions(expr, locator));
+                    b.setOptional(Boolean.valueOf(attributes.getValue("optional")));
+                    bundle.getBundleInfo().addRequiredBundle(b);
                 }
-                catch ( Exception e )
+                catch (Exception e)
                 {
-                    System.err.println( "Failed to parse filter in bundle " + bundle.getBundleInfo().getSymbolicName() );
-                    throw new SAXParseException( "Failed to parse filter in bundle "
-                        + bundle.getBundleInfo().getSymbolicName(), locator, e );
+                    System.err.println("Failed to parse filter in bundle "
+                        + bundle.getBundleInfo().getSymbolicName());
+                    throw new SAXParseException("Failed to parse filter in bundle "
+                        + bundle.getBundleInfo().getSymbolicName(), locator, e);
                 }
             }
             //else if ( "ee".equals( name ) ) {
@@ -252,125 +253,120 @@
         }
     }
 
-
-    private static VersionRange decodeVersions( LDAPExpr expr, Locator locator ) throws SAXParseException
+    private static VersionRange decodeVersions(LDAPExpr expr, Locator locator)
+        throws SAXParseException
     {
         try
         {
-            return VersionRangeHelper.decodeVersions( expr );
+            return VersionRangeHelper.decodeVersions(expr);
         }
-        catch ( NumberFormatException e )
+        catch (NumberFormatException e)
         {
-            throw new SAXParseException( e.getMessage(), locator );
+            throw new SAXParseException(e.getMessage(), locator);
         }
     }
 
-
-    private void startProperty( Attributes attributes )
+    private void startProperty(Attributes attributes)
     {
-        if ( export != null )
+        if (export != null)
         {
-            String name = attributes.getValue( "", "n" );
-            String value = attributes.getValue( "", "v" );
-            if ( PACKAGE.equals( name ) )
+            String name = attributes.getValue("", "n");
+            String value = attributes.getValue("", "v");
+            if (PACKAGE.equals(name))
             {
-                export.setPackageName( value );
+                export.setPackageName(value);
             }
-            else if ( "uses".equals( name ) )
+            else if ("uses".equals(name))
             {
-                String[] split = value.split( "," );
-                export.setUses( Arrays.asList( split ) );
+                String[] split = value.split(",");
+                export.setUses(Arrays.asList(split));
             }
-            else if ( "version".equals( name ) )
+            else if ("version".equals(name))
             {
-                export.setVersion( VersionTable.getVersion( value ) );
+                export.setVersion(VersionTable.getVersion(value));
             }
         }
     }
 
-
     private void endResource()
     {
-        if ( bundle != null )
+        if (bundle != null)
         {
-            listener.handleBundle( bundle );
+            listener.handleBundle(bundle);
             bundle = null;
         }
     }
 
-
     private void endCapability()
     {
-        if ( bundle != null )
+        if (bundle != null)
         {
-            if ( export != null )
+            if (export != null)
             {
-                bundle.getBundleInfo().addExport( export );
+                bundle.getBundleInfo().addExport(export);
                 export = null;
             }
         }
     }
 
-
     private void endRequire()
     {
         // TODO Auto-generated method stub
 
     }
 
-
     private void endProperty()
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    private static String decodePackage( LDAPExpr expr, Locator locator ) throws SAXParseException
+    private static String decodePackage(LDAPExpr expr, Locator locator)
+        throws SAXParseException
     {
-        ArrayList<SimpleTerm> terms = new ArrayList<SimpleTerm>( 1 );
+        ArrayList<SimpleTerm> terms = new ArrayList<SimpleTerm>(1);
 
-        findTerms( "package", expr, terms );
+        findTerms("package", expr, terms);
 
-        if ( terms.isEmpty() )
+        if (terms.isEmpty())
         {
-            throw new SAXParseException( "Missing name filter in " + expr, locator );
+            throw new SAXParseException("Missing name filter in " + expr, locator);
         }
 
-        return terms.get( 0 ).getRval();
+        return terms.get(0).getRval();
     }
 
-
-    private static String decodeSymbolicName( LDAPExpr expr, Locator locator ) throws SAXParseException
+    private static String decodeSymbolicName(LDAPExpr expr, Locator locator)
+        throws SAXParseException
     {
-        ArrayList<SimpleTerm> terms = new ArrayList<SimpleTerm>( 1 );
+        ArrayList<SimpleTerm> terms = new ArrayList<SimpleTerm>(1);
 
-        findTerms( "symbolicname", expr, terms );
+        findTerms("symbolicname", expr, terms);
 
-        if ( terms.isEmpty() )
+        if (terms.isEmpty())
         {
-            throw new SAXParseException( "Missing name filter in " + expr, locator );
+            throw new SAXParseException("Missing name filter in " + expr, locator);
         }
 
-        return terms.get( 0 ).getRval();
+        return terms.get(0).getRval();
     }
 
-
-    private static void findTerms( String string, LDAPExpr expr, List<SimpleTerm> terms ) throws SAXParseException
+    private static void findTerms(String string, LDAPExpr expr, List<SimpleTerm> terms)
+        throws SAXParseException
     {
-        if ( expr instanceof SimpleTerm )
+        if (expr instanceof SimpleTerm)
         {
-            SimpleTerm term = ( SimpleTerm ) expr;
-            if ( term.getName().equals( string ) )
+            SimpleTerm term = (SimpleTerm) expr;
+            if (term.getName().equals(string))
             {
-                terms.add( term );
+                terms.add(term);
             }
         }
         else
         {
-            for ( LDAPExpr c : expr.getChildren() )
+            for (LDAPExpr c : expr.getChildren())
             {
-                findTerms( string, c, terms );
+                findTerms(string, c, terms);
             }
         }
     }
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRListener.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRListener.java
index 107dd9c..12c9894 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRListener.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRListener.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.common.obr.impl;
 
-
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 
-
 public interface OBRListener
 {
-    void handleBundle( ISigilBundle bundle );
+    void handleBundle(ISigilBundle bundle);
 }
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/VersionRangeHelper.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/VersionRangeHelper.java
index 462e541..e5aff3a 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/VersionRangeHelper.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/VersionRangeHelper.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.obr.impl;
 
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -31,67 +30,68 @@
 import org.apache.felix.sigil.common.osgi.VersionTable;
 import org.osgi.framework.Version;
 
-
 public class VersionRangeHelper
 {
 
-    public static VersionRange decodeVersions( LDAPExpr expr ) throws NumberFormatException
+    public static VersionRange decodeVersions(LDAPExpr expr) throws NumberFormatException
     {
-        ArrayList<LDAPExpr> terms = new ArrayList<LDAPExpr>( 1 );
+        ArrayList<LDAPExpr> terms = new ArrayList<LDAPExpr>(1);
 
-        findExpr( "version", expr, terms );
+        findExpr("version", expr, terms);
 
-        if ( terms.isEmpty() )
+        if (terms.isEmpty())
         {
             // woo hoo!
             return VersionRange.ANY_VERSION;
         }
         else
         {
-            switch ( terms.size() )
+            switch (terms.size())
             {
                 case 1:
                 {
-                    return parseSimpleVersionRange( terms.get( 0 ) );
+                    return parseSimpleVersionRange(terms.get(0));
                 }
                 case 2:
                 {
-                    return parseCompoundVersionRange( terms.get( 0 ), terms.get( 1 ) );
+                    return parseCompoundVersionRange(terms.get(0), terms.get(1));
                 }
                 default:
                 {
                     // (&(version>=min)(!(version=min))(version<=max)(!(version=max))) 	- (min,max) - not dealt with!!
                     // (&(|(version>min)(version=min))(|(version<max)(version=max))) 	- [min,max] - not dealt with!!
-                    throw new NumberFormatException( "Failed to parse complicated version expression " + expr );
+                    throw new NumberFormatException(
+                        "Failed to parse complicated version expression " + expr);
                 }
             }
         }
     }
 
-
     // (&(version>=min)(version<=max)) 									- [min,max]
     // (&(version>min)(version<max))									- (min,max)
     //
     // (&(!(version<min))(!(version>max)))								- [min,max]
     // (&(!(version<=min))(!(version>=max)) 							- (min,max)
-    private static VersionRange parseCompoundVersionRange( LDAPExpr left, LDAPExpr right ) throws NumberFormatException
+    private static VersionRange parseCompoundVersionRange(LDAPExpr left, LDAPExpr right)
+        throws NumberFormatException
     {
-        VersionRange one = parseSimpleVersionRange( left );
-        VersionRange two = parseSimpleVersionRange( right );
+        VersionRange one = parseSimpleVersionRange(left);
+        VersionRange two = parseSimpleVersionRange(right);
 
         // sanity check
-        if ( one.isPointVersion() || two.isPointVersion() )
+        if (one.isPointVersion() || two.isPointVersion())
         {
-            throw new NumberFormatException( "Unexpected point version in compound expression " + left );
+            throw new NumberFormatException(
+                "Unexpected point version in compound expression " + left);
         }
 
-        VersionRange max = one.getFloor().equals( Version.emptyVersion ) ? one : two;
+        VersionRange max = one.getFloor().equals(Version.emptyVersion) ? one : two;
         VersionRange min = max == one ? two : one;
 
-        return new VersionRange( min.isOpenFloor(), min.getFloor(), max.getCeiling(), max.isOpenCeiling() );
+        return new VersionRange(min.isOpenFloor(), min.getFloor(), max.getCeiling(),
+            max.isOpenCeiling());
     }
 
-
     // possible variations				
     // (version=v)														- [v,v]
     //
@@ -105,122 +105,118 @@
     // (!(version<min))													- [min,*)
     // (!(version>=max))												- [0,max)
     // (!(version<=min))												- (0,*)
-    private static VersionRange parseSimpleVersionRange( LDAPExpr expr ) throws NumberFormatException
+    private static VersionRange parseSimpleVersionRange(LDAPExpr expr)
+        throws NumberFormatException
     {
         Version min = Version.emptyVersion;
         Version max = VersionRange.INFINITE_VERSION;
         boolean openFloor = false;
         boolean openCeiling = false;
-        if ( expr instanceof Not )
+        if (expr instanceof Not)
         {
-            Not n = ( Not ) expr;
-            SimpleTerm t = ( SimpleTerm ) n.getEx();
-            if ( t.getOp() == Ops.EQ )
+            Not n = (Not) expr;
+            SimpleTerm t = (SimpleTerm) n.getEx();
+            if (t.getOp() == Ops.EQ)
             {
-                throw new NumberFormatException( "Unexpected point version in negated expression " + expr );
+                throw new NumberFormatException(
+                    "Unexpected point version in negated expression " + expr);
             }
-            if ( !isMax( t.getOp() ) )
+            if (!isMax(t.getOp()))
             {
-                max = toVersion( t );
-                openCeiling = !openFloor( t );
+                max = toVersion(t);
+                openCeiling = !openFloor(t);
             }
-            else if ( !isMin( t.getOp() ) )
+            else if (!isMin(t.getOp()))
             {
-                min = toVersion( t );
-                openFloor = !openCeiling( t );
+                min = toVersion(t);
+                openFloor = !openCeiling(t);
             }
             else
             {
-                throw new IllegalStateException( "Unexpected operator " + t.getOp() );
+                throw new IllegalStateException("Unexpected operator " + t.getOp());
             }
         }
         else
         {
-            SimpleTerm t = ( SimpleTerm ) expr;
-            if ( t.getOp().equals( Ops.EQ ) )
+            SimpleTerm t = (SimpleTerm) expr;
+            if (t.getOp().equals(Ops.EQ))
             {
-                max = toVersion( t );
+                max = toVersion(t);
                 min = max;
                 openFloor = false;
                 openCeiling = false;
             }
-            else if ( isMax( t.getOp() ) )
+            else if (isMax(t.getOp()))
             {
-                max = toVersion( t );
-                openCeiling = openCeiling( t );
+                max = toVersion(t);
+                openCeiling = openCeiling(t);
             }
-            else if ( isMin( t.getOp() ) )
+            else if (isMin(t.getOp()))
             {
-                min = toVersion( t );
-                openFloor = openFloor( t );
+                min = toVersion(t);
+                openFloor = openFloor(t);
             }
             else
             {
-                throw new IllegalStateException( "Unexpected operator " + t.getOp() );
+                throw new IllegalStateException("Unexpected operator " + t.getOp());
             }
         }
 
-        return new VersionRange( openFloor, min, max, openCeiling );
+        return new VersionRange(openFloor, min, max, openCeiling);
     }
 
-
-    private static Version toVersion( SimpleTerm t )
+    private static Version toVersion(SimpleTerm t)
     {
-        return VersionTable.getVersion( t.getRval() );
+        return VersionTable.getVersion(t.getRval());
     }
 
-
-    private static boolean isMax( Ops op )
+    private static boolean isMax(Ops op)
     {
         return op == Ops.LE || op == Ops.LT;
     }
 
-
-    private static boolean isMin( Ops op )
+    private static boolean isMin(Ops op)
     {
         return op == Ops.GE || op == Ops.GT;
     }
 
-
-    private static boolean openFloor( SimpleTerm t )
+    private static boolean openFloor(SimpleTerm t)
     {
         return t.getOp() == Ops.GT;
     }
 
-
-    private static boolean openCeiling( SimpleTerm t )
+    private static boolean openCeiling(SimpleTerm t)
     {
         return t.getOp() == Ops.LT;
     }
 
-
-    private static void findExpr( String string, LDAPExpr expr, List<LDAPExpr> terms )
+    private static void findExpr(String string, LDAPExpr expr, List<LDAPExpr> terms)
     {
-        if ( expr instanceof SimpleTerm )
+        if (expr instanceof SimpleTerm)
         {
-            SimpleTerm term = ( SimpleTerm ) expr;
-            if ( term.getName().equals( string ) )
+            SimpleTerm term = (SimpleTerm) expr;
+            if (term.getName().equals(string))
             {
-                terms.add( term );
+                terms.add(term);
             }
         }
-        else if ( expr instanceof Not )
+        else if (expr instanceof Not)
         {
-            Not not = ( Not ) expr;
-            if ( not.getEx() instanceof SimpleTerm )
+            Not not = (Not) expr;
+            if (not.getEx() instanceof SimpleTerm)
             {
-                SimpleTerm term = ( SimpleTerm ) not.getEx();
-                if ( term.getName().equals( string ) )
+                SimpleTerm term = (SimpleTerm) not.getEx();
+                if (term.getName().equals(string))
                 {
-                    terms.add( not );
+                    terms.add(not);
                 }
             }
         }
         else
         {
-            for ( LDAPExpr c : expr.getChildren() )
+            for (LDAPExpr c : expr.getChildren())
             {
-                findExpr( string, c, terms );
+                findExpr(string, c, terms);
             }
         }
     }
diff --git a/sigil/common/osgi.test/src/org/apache/felix/sigil/common/osgi/LDAPParserTest.java b/sigil/common/osgi.test/src/org/apache/felix/sigil/common/osgi/LDAPParserTest.java
index f0720a3..d03bb31 100644
--- a/sigil/common/osgi.test/src/org/apache/felix/sigil/common/osgi/LDAPParserTest.java
+++ b/sigil/common/osgi.test/src/org/apache/felix/sigil/common/osgi/LDAPParserTest.java
@@ -23,40 +23,48 @@
 
 public class LDAPParserTest extends TestCase
 {
-    private static final SimpleTerm A_B = new SimpleTerm( "a", Ops.EQ, "b" );
-    private static final SimpleTerm C_D = new SimpleTerm( "c", Ops.EQ, "d" );
-    
-    public void testSimple() {
-        LDAPExpr expr = LDAPParser.parseExpression( "(a=b)" );
-        assertEquals( expr, A_B );
+    private static final SimpleTerm A_B = new SimpleTerm("a", Ops.EQ, "b");
+    private static final SimpleTerm C_D = new SimpleTerm("c", Ops.EQ, "d");
+
+    public void testSimple()
+    {
+        LDAPExpr expr = LDAPParser.parseExpression("(a=b)");
+        assertEquals(expr, A_B);
     }
 
-    public void testSimpleWhiteSpace() {
-        LDAPExpr expr = LDAPParser.parseExpression( "  ( a = b )  " );
-        assertEquals( expr, A_B );
+    public void testSimpleWhiteSpace()
+    {
+        LDAPExpr expr = LDAPParser.parseExpression("  ( a = b )  ");
+        assertEquals(expr, A_B);
     }
-    
-    public void testNot() {
-        LDAPExpr expr = LDAPParser.parseExpression( "(!(a=b))" );
-        assertEquals( expr, Not.apply(A_B));
+
+    public void testNot()
+    {
+        LDAPExpr expr = LDAPParser.parseExpression("(!(a=b))");
+        assertEquals(expr, Not.apply(A_B));
     }
-    
-    public void testAnd() {
-        LDAPExpr expr = LDAPParser.parseExpression( "(&(a=b)(c=d))" );
-        assertEquals( expr, And.apply(A_B, C_D) );
+
+    public void testAnd()
+    {
+        LDAPExpr expr = LDAPParser.parseExpression("(&(a=b)(c=d))");
+        assertEquals(expr, And.apply(A_B, C_D));
     }
-    
-    public void testOr() {
-        LDAPExpr expr = LDAPParser.parseExpression( "(|(a=b)(c=d))" );
-        assertEquals( expr, Or.apply(A_B, C_D) );
+
+    public void testOr()
+    {
+        LDAPExpr expr = LDAPParser.parseExpression("(|(a=b)(c=d))");
+        assertEquals(expr, Or.apply(A_B, C_D));
     }
-    
-    public void testParseException() {
-        try {
-            LDAPExpr expr = LDAPParser.parseExpression( ".(a=b)" );
-            fail( "Unexpectedly parsed invalid ldap expr " + expr);
+
+    public void testParseException()
+    {
+        try
+        {
+            LDAPExpr expr = LDAPParser.parseExpression(".(a=b)");
+            fail("Unexpectedly parsed invalid ldap expr " + expr);
         }
-        catch (LDAPParseException e) {
+        catch (LDAPParseException e)
+        {
             // expected
         }
     }
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/AbstractExpr.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/AbstractExpr.java
index fcb1084..144ae55 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/AbstractExpr.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/AbstractExpr.java
@@ -21,10 +21,12 @@
 
 public abstract class AbstractExpr implements LDAPExpr
 {
-    public void visit(ExprVisitor visitor) {
+    public void visit(ExprVisitor visitor)
+    {
         visitor.visitExpr(this);
-        for ( LDAPExpr expr : getChildren() ) {
-            visitor.visitExpr( expr );
+        for (LDAPExpr expr : getChildren())
+        {
+            visitor.visitExpr(expr);
         }
     }
 }
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java
index 4f99b15..3641bac 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.util.Map;
 
-
 public class And extends AbstractExpr
 {
 
@@ -31,58 +29,55 @@
     private static final long serialVersionUID = 1L;
     private LDAPExpr[] children;
 
-
-    public static LDAPExpr apply( LDAPExpr... terms )
+    public static LDAPExpr apply(LDAPExpr... terms)
     {
-        if ( terms == null )
+        if (terms == null)
         {
-            throw new NullPointerException( "terms cannot be null" );
+            throw new NullPointerException("terms cannot be null");
         }
-        else if ( terms.length == 0 )
+        else if (terms.length == 0)
         {
             return Expressions.T;
         }
-        else if ( terms.length == 1 )
+        else if (terms.length == 1)
         {
             return terms[0];
         }
         LDAPExpr[] filtered = new LDAPExpr[terms.length];
         int ctr = 0;
-        for ( int i = 0; i < terms.length; i++ )
+        for (int i = 0; i < terms.length; i++)
         {
-            if ( terms[i].equals( Expressions.F ) )
+            if (terms[i].equals(Expressions.F))
                 return Expressions.F;
-            if ( terms[i].equals( Expressions.T ) )
+            if (terms[i].equals(Expressions.T))
                 continue;
             filtered[ctr] = terms[i];
             ctr++;
         }
-        if ( ctr == 0 )
+        if (ctr == 0)
         {
             return Expressions.T;
         }
-        else if ( ctr == 1 )
+        else if (ctr == 1)
         {
             return filtered[0];
         }
         LDAPExpr[] andTerms = new LDAPExpr[ctr];
-        System.arraycopy( filtered, 0, andTerms, 0, ctr );
+        System.arraycopy(filtered, 0, andTerms, 0, ctr);
 
-        return new And( andTerms );
+        return new And(andTerms);
     }
 
-
-    private And( LDAPExpr... children )
+    private And(LDAPExpr... children)
     {
         this.children = children;
     }
 
-
-    public boolean eval( Map<String, ?> map )
+    public boolean eval(Map<String, ?> map)
     {
-        for ( int i = 0; i < children.length; i++ )
+        for (int i = 0; i < children.length; i++)
         {
-            if ( !children[i].eval( map ) )
+            if (!children[i].eval(map))
             {
                 return false;
             }
@@ -90,32 +85,29 @@
         return true;
     }
 
-
     public LDAPExpr[] getChildren()
     {
         return children;
     }
 
-
-    public void setChildren( LDAPExpr[] children )
+    public void setChildren(LDAPExpr[] children)
     {
         this.children = children;
     }
 
-
     @Override
-    public boolean equals( Object other )
+    public boolean equals(Object other)
     {
-        if ( other instanceof And )
+        if (other instanceof And)
         {
-            And that = ( And ) other;
-            if ( children.length != that.children.length )
+            And that = (And) other;
+            if (children.length != that.children.length)
             {
                 return false;
             }
-            for ( int i = 0; i < children.length; i++ )
+            for (int i = 0; i < children.length; i++)
             {
-                if ( !children[i].equals( that.children[i] ) )
+                if (!children[i].equals(that.children[i]))
                 {
                     return false;
                 }
@@ -125,17 +117,16 @@
         return false;
     }
 
-
     @Override
     public String toString()
     {
-        StringBuffer buf = new StringBuffer( 256 );
-        buf.append( "(&" );
-        for ( int i = 0; i < children.length; i++ )
+        StringBuffer buf = new StringBuffer(256);
+        buf.append("(&");
+        for (int i = 0; i < children.length; i++)
         {
-            buf.append( " " ).append( children[i] ).append( " " );
+            buf.append(" ").append(children[i]).append(" ");
         }
-        buf.append( ")" );
+        buf.append(")");
         return buf.toString();
     }
 
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java
index 88aa174..9cf5d36 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 public interface ExprVisitor
 {
     void visitExpr(LDAPExpr expr);
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java
index 6dab3ae..bb3cd81 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java
@@ -19,40 +19,35 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.util.Map;
 
-
 public class Expressions
 {
 
-    public static LDAPExpr and( LDAPExpr... terms )
+    public static LDAPExpr and(LDAPExpr... terms)
     {
-        return And.apply( terms );
+        return And.apply(terms);
     }
 
-
-    public static LDAPExpr or( LDAPExpr... terms )
+    public static LDAPExpr or(LDAPExpr... terms)
     {
-        return Or.apply( terms );
+        return Or.apply(terms);
     }
 
-
-    public static LDAPExpr not( LDAPExpr e )
+    public static LDAPExpr not(LDAPExpr e)
     {
-        return Not.apply( e );
+        return Not.apply(e);
     }
 
     public static LDAPExpr T = Bool.TRUE;
     public static LDAPExpr F = Bool.FALSE;
 
-
     // supports direct use of wildcards for ease of testing, but not literal *s
-    public static SimpleTerm ex( String name, Ops op, String rhs )
+    public static SimpleTerm ex(String name, Ops op, String rhs)
     {
 
-        rhs = rhs.replace( '*', SimpleTerm.WILDCARD );
-        return new SimpleTerm( name, op, rhs );
+        rhs = rhs.replace('*', SimpleTerm.WILDCARD);
+        return new SimpleTerm(name, op, rhs);
     }
 
 }
@@ -64,35 +59,30 @@
      * 
      */
     private static final long serialVersionUID = 1L;
-    public static final Bool TRUE = new Bool( true );
-    public static final Bool FALSE = new Bool( false );
+    public static final Bool TRUE = new Bool(true);
+    public static final Bool FALSE = new Bool(false);
 
     private boolean bool;
 
-
-    public Bool( boolean bool )
+    public Bool(boolean bool)
     {
         this.bool = bool;
     }
 
-
-    public boolean eval( Map<String, ?> map )
+    public boolean eval(Map<String, ?> map)
     {
         return bool;
     }
 
-
-    public void visit( ExprVisitor v )
+    public void visit(ExprVisitor v)
     {
     }
 
-
     public LDAPExpr[] getChildren()
     {
         return CHILDLESS;
     }
 
-
     public String toString()
     {
         return "(" + bool + ")";
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java
index 7b21e3d..b1c9d3d 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java
@@ -19,19 +19,17 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 public interface FilterValidator
 {
 
     public static FilterValidator ACCEPT_ALL = new AcceptEverythingValidator();
 
-
-    boolean validate( LDAPExpr filter );
+    boolean validate(LDAPExpr filter);
 
     static class AcceptEverythingValidator implements FilterValidator
     {
 
-        public boolean validate( LDAPExpr filter )
+        public boolean validate(LDAPExpr filter)
         {
             return true;
         }
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java
index d7b9bf0..5420d54 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java
@@ -19,30 +19,23 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.io.Serializable;
 import java.util.Map;
 
-
 public interface LDAPExpr extends Serializable
 {
 
     public static final LDAPExpr[] CHILDLESS = new LDAPExpr[0];
-    
-    public static LDAPExpr ACCEPT_ALL = Expressions.T;
 
+    public static LDAPExpr ACCEPT_ALL = Expressions.T;
 
     LDAPExpr[] getChildren();
 
+    void visit(ExprVisitor v);
 
-    void visit( ExprVisitor v );
-
-
-    boolean equals( Object other );
-
+    boolean equals(Object other);
 
     int hashCode();
 
-
-    boolean eval( Map<String, ?> map );
+    boolean eval(Map<String, ?> map);
 }
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java
index 6cbce7a..bb2d1b9 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java
@@ -19,45 +19,42 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 public class LDAPParseException extends RuntimeException
 {
     private static final long serialVersionUID = 2L;
 
     private ParseState ps;
-    private static final String LINE_SEPARATOR = System.getProperty( "line.separator", "\\r\\n" );
+    private static final String LINE_SEPARATOR = System.getProperty("line.separator",
+        "\\r\\n");
 
-
-    public LDAPParseException( String message, ParseState ps )
+    public LDAPParseException(String message, ParseState ps)
     {
-        super( message );
+        super(message);
         this.ps = ps;
     }
 
-
-    public LDAPParseException( String message )
+    public LDAPParseException(String message)
     {
-        super( message );
+        super(message);
     }
 
-
     @Override
     public String getMessage()
     {
-        if ( ps == null )
+        if (ps == null)
         {
             return super.getMessage();
         }
 
         String basicMessage = super.getMessage();
-        StringBuffer buf = new StringBuffer( basicMessage.length() + ps.str.length() * 2 );
-        buf.append( basicMessage ).append( LINE_SEPARATOR );
-        buf.append( ps.str ).append( LINE_SEPARATOR );
-        for ( int i = 0; i < ps.pos; i++ )
+        StringBuffer buf = new StringBuffer(basicMessage.length() + ps.str.length() * 2);
+        buf.append(basicMessage).append(LINE_SEPARATOR);
+        buf.append(ps.str).append(LINE_SEPARATOR);
+        for (int i = 0; i < ps.pos; i++)
         {
-            buf.append( " " );
+            buf.append(" ");
         }
-        buf.append( "^" );
+        buf.append("^");
         return buf.toString();
     }
 
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java
index aa0056a..de1cb51 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import static org.apache.felix.sigil.common.osgi.Expressions.and;
 import static org.apache.felix.sigil.common.osgi.Expressions.not;
 import static org.apache.felix.sigil.common.osgi.Expressions.or;
@@ -33,226 +32,219 @@
 import java.util.ArrayList;
 import java.util.List;
 
-
 public class LDAPParser
 {
 
     private static final LDAPParser parser = new LDAPParser();
 
-
-    public static LDAPExpr parseExpression( String strExpr ) throws LDAPParseException
+    public static LDAPExpr parseExpression(String strExpr) throws LDAPParseException
     {
-        return parser.parse( strExpr );
+        return parser.parse(strExpr);
     }
 
-    public LDAPExpr parse( String strExpr ) throws LDAPParseException
+    public LDAPExpr parse(String strExpr) throws LDAPParseException
     {
 
-        if ( strExpr == null || strExpr.trim().length() == 0 )
+        if (strExpr == null || strExpr.trim().length() == 0)
         {
             return LDAPExpr.ACCEPT_ALL;
         }
 
-        ParseState ps = new ParseState( strExpr );
-        LDAPExpr expr = parseExpr( ps );
+        ParseState ps = new ParseState(strExpr);
+        LDAPExpr expr = parseExpr(ps);
         ps.skipWhitespace();
-        if ( !ps.isEndOfString() )
+        if (!ps.isEndOfString())
         {
-            error( "expected end of expression ", ps );
+            error("expected end of expression ", ps);
         }
         return expr;
     }
 
-
-    public LDAPExpr parseExpr( ParseState ps ) throws LDAPParseException
+    public LDAPExpr parseExpr(ParseState ps) throws LDAPParseException
     {
         ps.skipWhitespace();
-        if ( !( ps.peek() == '(' ) )
+        if (!(ps.peek() == '('))
         {
-            error( "expected (", ps );
+            error("expected (", ps);
         }
         ps.read();
         LDAPExpr expr = null;
         ps.skipWhitespace();
         char ch = ps.peek();
-        switch ( ch )
+        switch (ch)
         {
             case '&':
                 ps.readAndSkipWhiteSpace();
                 List<LDAPExpr> andList = new ArrayList<LDAPExpr>();
-                while ( ps.peek() == '(' )
+                while (ps.peek() == '(')
                 {
-                    andList.add( parseExpr( ps ) );
+                    andList.add(parseExpr(ps));
                     ps.skipWhitespace();
                 }
-                LDAPExpr[] andArr = andList.toArray( new LDAPExpr[andList.size()] );
-                expr = and( andArr );
+                LDAPExpr[] andArr = andList.toArray(new LDAPExpr[andList.size()]);
+                expr = and(andArr);
                 break;
             case '|':
                 ps.readAndSkipWhiteSpace();
                 List<LDAPExpr> orList = new ArrayList<LDAPExpr>();
-                while ( ps.peek() == '(' )
+                while (ps.peek() == '(')
                 {
-                    orList.add( parseExpr( ps ) );
+                    orList.add(parseExpr(ps));
                     ps.skipWhitespace();
                 }
-                LDAPExpr[] orArray = orList.toArray( new LDAPExpr[orList.size()] );
-                expr = or( orArray );
+                LDAPExpr[] orArray = orList.toArray(new LDAPExpr[orList.size()]);
+                expr = or(orArray);
                 break;
             case '!':
                 ps.readAndSkipWhiteSpace();
-                expr = not( parseExpr( ps ) );
+                expr = not(parseExpr(ps));
                 break;
             default:
-                if ( isNameChar( ch ) )
+                if (isNameChar(ch))
                 {
-                    expr = parseSimple( ps );
+                    expr = parseSimple(ps);
                 }
                 else
                 {
-                    error( "unexpected character: '" + ch + "'", ps );
+                    error("unexpected character: '" + ch + "'", ps);
                 }
         }
         ps.skipWhitespace();
-        if ( ps.peek() != ')' )
+        if (ps.peek() != ')')
         {
-            error( "expected )", ps );
+            error("expected )", ps);
         }
         ps.read();
         return expr;
 
     }
 
-
-    void error( String message, ParseState ps ) throws LDAPParseException
+    void error(String message, ParseState ps) throws LDAPParseException
     {
-        throw new LDAPParseException( message, ps );
+        throw new LDAPParseException(message, ps);
     }
 
-
-    private SimpleTerm parseSimple( ParseState ps ) throws LDAPParseException
+    private SimpleTerm parseSimple(ParseState ps) throws LDAPParseException
     {
         // read name
-        StringBuffer name = new StringBuffer( 16 );
-        for ( char c = ps.peek(); !ps.isEndOfString() && isNameChar( c ); c = ps.peek() )
+        StringBuffer name = new StringBuffer(16);
+        for (char c = ps.peek(); !ps.isEndOfString() && isNameChar(c); c = ps.peek())
         {
             ps.read();
-            name.append( c );
+            name.append(c);
         }
         ps.skipWhitespace();
         Ops op = null;
         // read op
-        if ( ps.lookingAt( "=" ) )
+        if (ps.lookingAt("="))
         {
             op = EQ;
-            ps.skip( 1 );
+            ps.skip(1);
         }
-        else if ( ps.lookingAt( ">=" ) )
+        else if (ps.lookingAt(">="))
         {
             op = GE;
-            ps.skip( 2 );
+            ps.skip(2);
         }
-        else if ( ps.lookingAt( "<=" ) )
+        else if (ps.lookingAt("<="))
         {
             op = LE;
-            ps.skip( 2 );
+            ps.skip(2);
         }
-        else if ( ps.lookingAt( ">" ) )
+        else if (ps.lookingAt(">"))
         {
             op = GT;
-            ps.skip( 1 );
+            ps.skip(1);
         }
-        else if ( ps.lookingAt( "<" ) )
+        else if (ps.lookingAt("<"))
         {
             op = LT;
-            ps.skip( 1 );
+            ps.skip(1);
         }
-        else if ( ps.lookingAt( "-=" ) )
+        else if (ps.lookingAt("-="))
         {
             op = APPROX;
-            ps.skip( 2 );
+            ps.skip(2);
         }
-        else if ( ps.isEndOfString() )
+        else if (ps.isEndOfString())
         {
-            error( "unexpected end of expression", ps );
+            error("unexpected end of expression", ps);
         }
         else
         {
-            error( "unexpected character: '" + ps.peek() + "'", ps );
+            error("unexpected character: '" + ps.peek() + "'", ps);
         }
         ps.skipWhitespace();
 
         boolean escaped = false;
-        StringBuffer value = new StringBuffer( 16 );
+        StringBuffer value = new StringBuffer(16);
 
-        while ( !ps.isEndOfString() && !Character.isWhitespace( ps.peek() ) && !( ps.peek() == ')' && !escaped ) )
+        while (!ps.isEndOfString() && !Character.isWhitespace(ps.peek())
+            && !(ps.peek() == ')' && !escaped))
         {
 
             char ch = ps.peek();
 
-            if ( ch == '\\' )
+            if (ch == '\\')
             {
                 escaped = true;
                 ps.read();
             }
-            else if ( ch == '*' )
+            else if (ch == '*')
             {
-                if ( escaped )
+                if (escaped)
                 {
-                    value.append( ch );
+                    value.append(ch);
                     escaped = false;
                 }
                 else
                 {
-                    value.append( SimpleTerm.WILDCARD );
+                    value.append(SimpleTerm.WILDCARD);
                 }
                 ps.read();
             }
-            else if ( isLiteralValue( ch ) )
+            else if (isLiteralValue(ch))
             {
-                if ( escaped )
+                if (escaped)
                 {
-                    error( "incorrectly applied escape of '" + ch + "'", ps );
+                    error("incorrectly applied escape of '" + ch + "'", ps);
                 }
-                value.append( ps.read() );
+                value.append(ps.read());
             }
-            else if ( isEscapedValue( ch ) )
+            else if (isEscapedValue(ch))
             {
-                if ( !escaped )
+                if (!escaped)
                 {
-                    error( "missing escape for '" + ch + "'", ps );
+                    error("missing escape for '" + ch + "'", ps);
                 }
-                value.append( ps.read() );
+                value.append(ps.read());
                 escaped = false;
             }
             else
             {
-                error( "unexpected character: '" + ps.peek() + "'", ps );
+                error("unexpected character: '" + ps.peek() + "'", ps);
             }
         }
         ps.skipWhitespace();
 
-        SimpleTerm expr = new SimpleTerm( name.toString(), op, value.toString() );
+        SimpleTerm expr = new SimpleTerm(name.toString(), op, value.toString());
 
         return expr;
     }
 
-
-    private boolean isNameChar( int ch )
+    private boolean isNameChar(int ch)
     {
-        return !( Character.isWhitespace( ch ) || ( ch == '(' ) || ( ch == ')' ) || ( ch == '<' ) || ( ch == '>' )
-            || ( ch == '=' ) || ( ch == '~' ) || ( ch == '*' ) || ( ch == '\\' ) );
+        return !(Character.isWhitespace(ch) || (ch == '(') || (ch == ')') || (ch == '<')
+            || (ch == '>') || (ch == '=') || (ch == '~') || (ch == '*') || (ch == '\\'));
     }
 
-
-    private boolean isLiteralValue( int ch )
+    private boolean isLiteralValue(int ch)
     {
-        return !( Character.isWhitespace( ch ) || ( ch == '(' ) || ( ch == ')' ) || ( ch == '*' ) );
+        return !(Character.isWhitespace(ch) || (ch == '(') || (ch == ')') || (ch == '*'));
     }
 
-
-    private boolean isEscapedValue( int ch )
+    private boolean isEscapedValue(int ch)
     {
-        return ( ch == '(' ) || ( ch == ')' ) || ( ch == '*' );
+        return (ch == '(') || (ch == ')') || (ch == '*');
     }
 }
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java
index 0b3480d..70b423d 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.util.Map;
 
-
 public class Not extends AbstractExpr
 {
 
@@ -32,76 +30,66 @@
     private static final long serialVersionUID = 1L;
     private LDAPExpr[] children;
 
-
-    public static LDAPExpr apply( LDAPExpr e )
+    public static LDAPExpr apply(LDAPExpr e)
     {
-        if ( e == null )
+        if (e == null)
         {
-            throw new NullPointerException( "cannot apply Not to a null expression" );
+            throw new NullPointerException("cannot apply Not to a null expression");
         }
-        if ( e.equals( Expressions.T ) )
+        if (e.equals(Expressions.T))
         {
             return Expressions.F;
         }
-        if ( e.equals( Expressions.F ) )
+        if (e.equals(Expressions.F))
         {
             return Expressions.T;
         }
-        return new Not( e );
+        return new Not(e);
     }
 
-
-    private Not( LDAPExpr child )
+    private Not(LDAPExpr child)
     {
-        this.children = new LDAPExpr[]
-            { child };
+        this.children = new LDAPExpr[] { child };
     }
 
-
-    public boolean eval( Map<String, ?> map )
+    public boolean eval(Map<String, ?> map)
     {
-        return !children[0].eval( map );
+        return !children[0].eval(map);
     }
 
-
     public LDAPExpr getEx()
     {
         return children[0];
     }
 
-
     public LDAPExpr[] getChildren()
     {
         return children;
     }
 
-
-    public void setChild( LDAPExpr child )
+    public void setChild(LDAPExpr child)
     {
-        this.children = new LDAPExpr[]
-            { child };
+        this.children = new LDAPExpr[] { child };
     }
 
-
     @Override
-    public boolean equals( Object other )
+    public boolean equals(Object other)
     {
-        if ( other instanceof Not )
+        if (other instanceof Not)
         {
-            Not that = ( Not ) other;
-            return children[0].equals( that.children[0] );
+            Not that = (Not) other;
+            return children[0].equals(that.children[0]);
         }
         return false;
     }
 
-
     @Override
     public String toString()
     {
-        StringBuffer buf = new StringBuffer( 256 );
-        buf.append( "(!" );
-        buf.append( " " ).append( children[0] ).append( " " );
-        buf.append( ")" );
+        StringBuffer buf = new StringBuffer(256);
+        buf.append("(!");
+        buf.append(" ").append(children[0]).append(" ");
+        buf.append(")");
         return buf.toString();
     }
 
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java
index 200e497..05d66b9 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 public enum Ops
 {
     EQ, GE, LE, GT, LT, APPROX;
@@ -27,7 +26,7 @@
     @Override
     public String toString()
     {
-        switch ( this )
+        switch (this)
         {
             case EQ:
                 return "=";
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java
index 5b6e215..7d5e32c 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.util.Map;
 
-
 public class Or extends AbstractExpr
 {
 
@@ -32,58 +30,55 @@
     private static final long serialVersionUID = 1L;
     private LDAPExpr[] children;
 
-
-    public static LDAPExpr apply( LDAPExpr... terms )
+    public static LDAPExpr apply(LDAPExpr... terms)
     {
-        if ( terms == null )
+        if (terms == null)
         {
-            throw new NullPointerException( "terms cannot be null" );
+            throw new NullPointerException("terms cannot be null");
         }
-        else if ( terms.length == 0 )
+        else if (terms.length == 0)
         {
             return Expressions.T;
         }
-        else if ( terms.length == 1 )
+        else if (terms.length == 1)
         {
             return terms[0];
         }
         LDAPExpr[] filtered = new LDAPExpr[terms.length];
         int ctr = 0;
-        for ( int i = 0; i < terms.length; i++ )
+        for (int i = 0; i < terms.length; i++)
         {
-            if ( terms[i].equals( Expressions.T ) )
+            if (terms[i].equals(Expressions.T))
                 return Expressions.T;
-            if ( terms[i].equals( Expressions.F ) )
+            if (terms[i].equals(Expressions.F))
                 continue;
             filtered[ctr] = terms[i];
             ctr++;
         }
-        if ( ctr == 0 )
+        if (ctr == 0)
         {
             return Expressions.F;
         }
-        else if ( ctr == 1 )
+        else if (ctr == 1)
         {
             return filtered[0];
         }
         LDAPExpr[] orTerms = new LDAPExpr[ctr];
-        System.arraycopy( filtered, 0, orTerms, 0, ctr );
+        System.arraycopy(filtered, 0, orTerms, 0, ctr);
 
-        return new Or( orTerms );
+        return new Or(orTerms);
     }
 
-
-    private Or( LDAPExpr... children )
+    private Or(LDAPExpr... children)
     {
         this.children = children;
     }
 
-
-    public boolean eval( Map<String, ?> map )
+    public boolean eval(Map<String, ?> map)
     {
-        for ( int i = 0; i < children.length; i++ )
+        for (int i = 0; i < children.length; i++)
         {
-            if ( children[i].eval( map ) )
+            if (children[i].eval(map))
             {
                 return true;
             }
@@ -91,32 +86,29 @@
         return false;
     }
 
-
     public LDAPExpr[] getChildren()
     {
         return children;
     }
 
-
-    public void setChildren( LDAPExpr[] children )
+    public void setChildren(LDAPExpr[] children)
     {
         this.children = children;
     }
 
-
     @Override
-    public boolean equals( Object other )
+    public boolean equals(Object other)
     {
-        if ( other instanceof Or )
+        if (other instanceof Or)
         {
-            Or that = ( Or ) other;
-            if ( children.length != that.children.length )
+            Or that = (Or) other;
+            if (children.length != that.children.length)
             {
                 return false;
             }
-            for ( int i = 0; i < children.length; i++ )
+            for (int i = 0; i < children.length; i++)
             {
-                if ( children[i].equals( that.children[i] ) )
+                if (children[i].equals(that.children[i]))
                 {
                     return true;
                 }
@@ -126,17 +118,16 @@
         return false;
     }
 
-
     @Override
     public String toString()
     {
-        StringBuffer buf = new StringBuffer( 256 );
-        buf.append( "(|" );
-        for ( int i = 0; i < children.length; i++ )
+        StringBuffer buf = new StringBuffer(256);
+        buf.append("(|");
+        for (int i = 0; i < children.length; i++)
         {
-            buf.append( " " ).append( children[i] ).append( " " );
+            buf.append(" ").append(children[i]).append(" ");
         }
-        buf.append( ")" );
+        buf.append(")");
         return buf.toString();
     }
 
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java
index 5bfb77b..f7f502d 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.io.Serializable;
 
-
 /**
  * @author dave
  * 
@@ -35,39 +33,34 @@
 
     String str;
 
-
-    ParseState( String str )
+    ParseState(String str)
     {
         this.str = str;
     }
 
-
-    public boolean lookingAt( String start )
+    public boolean lookingAt(String start)
     {
-        return str.substring( pos ).startsWith( start );
+        return str.substring(pos).startsWith(start);
     }
 
-
-    public CharSequence skip( int n )
+    public CharSequence skip(int n)
     {
         int end = pos + n < str.length() ? pos + n : str.length();
         int start = pos;
         pos = end;
-        return str.subSequence( start, end );
+        return str.subSequence(start, end);
     }
 
-
     public char read()
     {
-        char ch = str.charAt( pos );
-        if ( pos < str.length() )
+        char ch = str.charAt(pos);
+        if (pos < str.length())
         {
             pos++;
         }
         return ch;
     }
 
-
     public char readAndSkipWhiteSpace()
     {
         char ch = read();
@@ -75,26 +68,23 @@
         return ch;
     }
 
-
     char peek()
     {
-        if ( isEndOfString() )
+        if (isEndOfString())
         {
-            return ( char ) -1;
+            return (char) -1;
         }
-        return str.charAt( pos );
+        return str.charAt(pos);
     }
 
-
     boolean isEndOfString()
     {
         return pos == str.length();
     }
 
-
     void skipWhitespace()
     {
-        while ( pos < str.length() && Character.isWhitespace( str.charAt( pos ) ) )
+        while (pos < str.length() && Character.isWhitespace(str.charAt(pos)))
         {
             pos++;
         }
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java
index ffbe7dc..cb38204 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java
@@ -19,13 +19,11 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.lang.reflect.Constructor;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Vector;
 
-
 public class SimpleTerm extends AbstractExpr
 {
 
@@ -34,59 +32,54 @@
      */
     private static final long serialVersionUID = 1L;
     public static final char WILDCARD = 2 ^ 16 - 1;
-    private static final String WILDCARD_STRING = new String( new char[]
-        { SimpleTerm.WILDCARD } );
+    private static final String WILDCARD_STRING = new String(
+        new char[] { SimpleTerm.WILDCARD });
 
     private Ops op;
     private String name;
     private String rval;
 
-
-    public SimpleTerm( String name, Ops op, String value )
+    public SimpleTerm(String name, Ops op, String value)
     {
         this.op = op;
         this.name = name.intern();
         this.rval = value.intern();
     }
 
-
     public String getName()
     {
         return name;
     }
 
-
     public Ops getOp()
     {
         return op;
     }
 
-
     public String getRval()
     {
         return rval;
     }
 
-
-    public boolean eval( Map<String, ?> map )
+    public boolean eval(Map<String, ?> map)
     {
 
-        Object lval = map.get( name );
-        if ( lval == null )
+        Object lval = map.get(name);
+        if (lval == null)
         {
             return false;
         }
-        else if ( Ops.EQ == op && WILDCARD_STRING.equals( lval ) )
+        else if (Ops.EQ == op && WILDCARD_STRING.equals(lval))
         {
             return true;
         }
         // any match in the vector will do
-        else if ( lval instanceof Vector<?> )
+        else if (lval instanceof Vector<?>)
         {
-            Vector<?> vec = ( Vector<?> ) lval;
-            for ( Iterator<?> i = vec.iterator(); i.hasNext(); )
+            Vector<?> vec = (Vector<?>) lval;
+            for (Iterator<?> i = vec.iterator(); i.hasNext();)
             {
-                if ( check( i.next() ) )
+                if (check(i.next()))
                 {
                     return true;
                 }
@@ -94,85 +87,84 @@
             return false;
         }
         // any match in the array will do
-        else if ( lval instanceof Object[] )
+        else if (lval instanceof Object[])
         {
-            Object[] arr = ( Object[] ) lval;
-            for ( int i = 0; i < arr.length; i++ )
+            Object[] arr = (Object[]) lval;
+            for (int i = 0; i < arr.length; i++)
             {
-                if ( check( arr[i] ) )
+                if (check(arr[i]))
                 {
                     return true;
                 }
             }
             return false;
         }
-        return check( lval );
+        return check(lval);
     }
 
-
     @SuppressWarnings("unchecked")
-    private boolean check( Object lval )
+    private boolean check(Object lval)
     {
-        if ( lval == null )
+        if (lval == null)
         {
             return false;
         }
-        else if ( Ops.EQ == op && WILDCARD_STRING.equals( lval ) )
+        else if (Ops.EQ == op && WILDCARD_STRING.equals(lval))
         {
             return true;
         }
 
         Object rhs = null;
 
-        if ( lval instanceof String )
+        if (lval instanceof String)
         {
 
-            if ( Ops.APPROX == op )
+            if (Ops.APPROX == op)
             {
-                rhs = collapseWhiteSpace( rval );
-                lval = collapseWhiteSpace( ( String ) lval );
+                rhs = collapseWhiteSpace(rval);
+                lval = collapseWhiteSpace((String) lval);
             }
 
-            if ( Ops.EQ == op || Ops.APPROX == op )
+            if (Ops.EQ == op || Ops.APPROX == op)
             {
-                return stringCheck( ( String ) lval );
+                return stringCheck((String) lval);
             }
             // rhs already a string
 
         }
-        else if ( lval.getClass() == Byte.class )
+        else if (lval.getClass() == Byte.class)
         {
-            rhs = Byte.valueOf( rval );
+            rhs = Byte.valueOf(rval);
         }
-        else if ( lval.getClass() == Short.class )
+        else if (lval.getClass() == Short.class)
         {
-            rhs = Short.valueOf( rval );
+            rhs = Short.valueOf(rval);
         }
-        else if ( lval.getClass() == Integer.class )
+        else if (lval.getClass() == Integer.class)
         {
-            rhs = Integer.valueOf( rval );
+            rhs = Integer.valueOf(rval);
         }
-        else if ( lval.getClass() == Long.class )
+        else if (lval.getClass() == Long.class)
         {
-            rhs = Long.valueOf( rval );
+            rhs = Long.valueOf(rval);
         }
-        else if ( lval.getClass() == Float.class )
+        else if (lval.getClass() == Float.class)
         {
-            rhs = Float.valueOf( rval );
+            rhs = Float.valueOf(rval);
         }
-        else if ( lval.getClass() == Double.class )
+        else if (lval.getClass() == Double.class)
         {
-            rhs = Double.valueOf( rval );
+            rhs = Double.valueOf(rval);
         }
         else
         {
             try
             {
-                Constructor<?> stringCtor = lval.getClass().getConstructor( new Class[]
-                    { String.class } );
-                rhs = stringCtor.newInstance( rval );
+                Constructor<?> stringCtor = lval.getClass().getConstructor(
+                    new Class[] { String.class });
+                rhs = stringCtor.newInstance(rval);
             }
-            catch ( Exception e )
+            catch (Exception e)
             {
                 // log it
                 e.printStackTrace();
@@ -180,18 +172,18 @@
             }
         }
 
-        if ( !( lval instanceof Comparable ) )
+        if (!(lval instanceof Comparable))
         {
-            return Ops.EQ == op && lval.equals( rval );
+            return Ops.EQ == op && lval.equals(rval);
         }
         else
         {
 
-            Comparable<? super Object> lhs = ( Comparable<? super Object> ) lval;
+            Comparable<? super Object> lhs = (Comparable<? super Object>) lval;
 
-            int compare = lhs.compareTo( rhs );
+            int compare = lhs.compareTo(rhs);
 
-            switch ( op )
+            switch (op)
             {
                 case EQ:
                     return compare == 0;
@@ -211,12 +203,11 @@
         return false;
     }
 
-
-    private boolean stringCheck( String lhs )
+    private boolean stringCheck(String lhs)
     {
 
         String rhs;
-        switch ( op )
+        switch (op)
         {
             case EQ:
             case APPROX:
@@ -229,35 +220,35 @@
         int valLength = lhs.length();
         int patLength = rval.length();
 
-        if ( valLength == 0 && patLength == 0 )
+        if (valLength == 0 && patLength == 0)
         {
             return true;
         }
 
         boolean wc = false;
         int j = 0;
-        for ( int i = 0; i < patLength; i++ )
+        for (int i = 0; i < patLength; i++)
         {
             // trailing wildcards
-            char pc = rhs.charAt( i );
-            if ( j == valLength )
+            char pc = rhs.charAt(i);
+            if (j == valLength)
             {
-                if ( pc != SimpleTerm.WILDCARD )
+                if (pc != SimpleTerm.WILDCARD)
                 {
                     return false;
                 }
                 continue;
             }
-            if ( pc == SimpleTerm.WILDCARD )
+            if (pc == SimpleTerm.WILDCARD)
             {
                 wc = true;
                 continue;
             }
-            while ( wc && j < valLength - 1 && lhs.charAt( j ) != pc )
+            while (wc && j < valLength - 1 && lhs.charAt(j) != pc)
             {
                 j++;
             }
-            if ( lhs.charAt( j ) != pc )
+            if (lhs.charAt(j) != pc)
             {
                 return false;
             }
@@ -267,79 +258,74 @@
                 j++;
             }
         }
-        return ( wc || j == valLength );
+        return (wc || j == valLength);
 
     }
 
-
-    private String collapseWhiteSpace( String in )
+    private String collapseWhiteSpace(String in)
     {
-        StringBuffer out = new StringBuffer( in.trim().length() );
+        StringBuffer out = new StringBuffer(in.trim().length());
         boolean white = false;
-        for ( int i = 0; i < in.length(); i++ )
+        for (int i = 0; i < in.length(); i++)
         {
-            char ch = in.charAt( i );
-            if ( Character.isWhitespace( ch ) )
+            char ch = in.charAt(i);
+            if (Character.isWhitespace(ch))
             {
                 white = true;
             }
             else
             {
-                if ( white )
+                if (white)
                 {
-                    out.append( " " );
+                    out.append(" ");
                     white = false;
                 }
-                out.append( ch );
+                out.append(ch);
             }
         }
         return out.toString();
     }
 
-
     public LDAPExpr[] getChildren()
     {
         return CHILDLESS;
     }
 
-
     @Override
-    public boolean equals( Object other )
+    public boolean equals(Object other)
     {
-        if ( other instanceof SimpleTerm )
+        if (other instanceof SimpleTerm)
         {
-            SimpleTerm that = ( SimpleTerm ) other;
-            return name.equals( that.name ) && op.equals( that.op ) && rval.equals( that.rval );
+            SimpleTerm that = (SimpleTerm) other;
+            return name.equals(that.name) && op.equals(that.op) && rval.equals(that.rval);
         }
         return false;
     }
 
-
     @Override
     public String toString()
     {
-        return "(" + name + " " + op.toString() + " " + escape( rval ) + ")";
+        return "(" + name + " " + op.toString() + " " + escape(rval) + ")";
     }
 
-
-    private String escape( String raw )
+    private String escape(String raw)
     {
-        StringBuffer buf = new StringBuffer( raw.length() + 10 );
-        for ( int i = 0; i < raw.length(); i++ )
+        StringBuffer buf = new StringBuffer(raw.length() + 10);
+        for (int i = 0; i < raw.length(); i++)
         {
-            char ch = raw.charAt( i );
-            switch ( ch )
+            char ch = raw.charAt(i);
+            switch (ch)
             {
                 case SimpleTerm.WILDCARD:
-                    buf.append( "*" );
+                    buf.append("*");
                     break;
                 case '(':
                 case ')':
                 case '*':
-                    buf.append( "\\" ).append( ch );
+                    buf.append("\\").append(ch);
                     break;
                 default:
-                    buf.append( ch );
+                    buf.append(ch);
             }
         }
         return buf.toString();
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java
index 9720702..feed6e8 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java
@@ -19,47 +19,44 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-
 public class Utils
 {
-    public static MapBuilder map( String name, Object value )
+    public static MapBuilder map(String name, Object value)
     {
-        return new MapBuilder().put( name, value );
+        return new MapBuilder().put(name, value);
     }
 
-
-    public static String toString( Map<String, Object> attrs )
+    public static String toString(Map<String, Object> attrs)
     {
-        if ( attrs == null )
+        if (attrs == null)
         {
             return "NULL";
         }
 
-        StringBuffer buf = new StringBuffer( 128 );
-        List<String> keys = new ArrayList<String>( attrs.keySet() );
-        Collections.sort( keys );
-        buf.append( "{" );
+        StringBuffer buf = new StringBuffer(128);
+        List<String> keys = new ArrayList<String>(attrs.keySet());
+        Collections.sort(keys);
+        buf.append("{");
 
-        for ( int i = 0; i < keys.size(); i++ )
+        for (int i = 0; i < keys.size(); i++)
         {
-            Object name = keys.get( i );
-            Object value = attrs.get( name );
-            buf.append( name ).append( "=" ).append( value ).append( "," );
+            Object name = keys.get(i);
+            Object value = attrs.get(name);
+            buf.append(name).append("=").append(value).append(",");
         }
 
-        if ( buf.length() > 1 )
+        if (buf.length() > 1)
         {
-            buf.delete( buf.length() - 1, buf.length() );
+            buf.delete(buf.length() - 1, buf.length());
         }
 
-        buf.append( "}" );
+        buf.append("}");
 
         return buf.toString();
     }
@@ -68,15 +65,13 @@
     {
         private Map<String, Object> map = new HashMap<String, Object>();
 
-
-        public MapBuilder put( String name, Object value )
+        public MapBuilder put(String name, Object value)
         {
-            map.put( name, value );
+            map.put(name, value);
 
             return this;
         }
 
-
         public Map<String, Object> toMap()
         {
             return map;
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java
index 321f4e2..a3ec95c 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java
@@ -19,12 +19,10 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 import java.io.Serializable;
 
 import org.osgi.framework.Version;
 
-
 public class VersionRange implements Serializable
 {
 
@@ -32,17 +30,16 @@
      * 
      */
     private static final long serialVersionUID = 1L;
-    public static final Version INFINITE_VERSION = new Version( Integer.MAX_VALUE, Integer.MAX_VALUE,
-        Integer.MAX_VALUE, "" );
-    public static final VersionRange ANY_VERSION = new VersionRange( false, Version.emptyVersion, INFINITE_VERSION,
-        true );
+    public static final Version INFINITE_VERSION = new Version(Integer.MAX_VALUE,
+        Integer.MAX_VALUE, Integer.MAX_VALUE, "");
+    public static final VersionRange ANY_VERSION = new VersionRange(false,
+        Version.emptyVersion, INFINITE_VERSION, true);
 
     private boolean openFloor;
     private Version floor;
     private Version ceiling;
     private boolean openCeiling;
 
-
     /**
      * Interval constructor
      * 
@@ -51,7 +48,7 @@
      * @param ceiling The upper bound version of the range.
      * @param openCeiling Whether the upper bound of the range is inclusive (false) or exclusive (true).
      */
-    public VersionRange( boolean openFloor, Version floor, Version ceiling, boolean openCeiling )
+    public VersionRange(boolean openFloor, Version floor, Version ceiling, boolean openCeiling)
     {
         this.openFloor = openFloor;
         this.floor = floor;
@@ -59,14 +56,13 @@
         this.openCeiling = openCeiling;
     }
 
-
     /**
      * atLeast constructor
      * 
      * @param openFloor
      * @param floor
      */
-    public VersionRange( Version atLeast )
+    public VersionRange(Version atLeast)
     {
         this.openFloor = false;
         this.floor = atLeast;
@@ -74,202 +70,198 @@
         this.openCeiling = true;
     }
 
-
-    public static VersionRange parseVersionRange( String val ) throws IllegalArgumentException, NumberFormatException
+    public static VersionRange parseVersionRange(String val)
+        throws IllegalArgumentException, NumberFormatException
     {
-        if ( val == null || val.trim().length() == 0 )
+        if (val == null || val.trim().length() == 0)
         {
             return ANY_VERSION;
         }
 
         boolean openFloor;
         boolean openCeiling;
-        val = val.replaceAll( "\\s", "" );
-        val = val.replaceAll( "\"", "" );
-        int fst = val.charAt( 0 );
-        if ( fst == '[' )
+        val = val.replaceAll("\\s", "");
+        val = val.replaceAll("\"", "");
+        int fst = val.charAt(0);
+        if (fst == '[')
         {
             openFloor = false;
         }
-        else if ( fst == '(' )
+        else if (fst == '(')
         {
             openFloor = true;
         }
         else
         {
-            Version atLeast = VersionTable.getVersion( val );
-            return new VersionRange( atLeast );
+            Version atLeast = VersionTable.getVersion(val);
+            return new VersionRange(atLeast);
         }
 
-        int lst = val.charAt( val.length() - 1 );
-        if ( lst == ']' )
+        int lst = val.charAt(val.length() - 1);
+        if (lst == ']')
         {
             openCeiling = false;
         }
-        else if ( lst == ')' )
+        else if (lst == ')')
         {
             openCeiling = true;
         }
         else
         {
-            throw new IllegalArgumentException( "illegal version range syntax " + val
-                + ": range must end in ')' or ']'" );
+            throw new IllegalArgumentException("illegal version range syntax " + val
+                + ": range must end in ')' or ']'");
         }
 
-        String inner = val.substring( 1, val.length() - 1 );
-        String[] floorCeiling = inner.split( "," );
-        if ( floorCeiling.length != 2 )
+        String inner = val.substring(1, val.length() - 1);
+        String[] floorCeiling = inner.split(",");
+        if (floorCeiling.length != 2)
         {
-            throw new IllegalArgumentException( "illegal version range syntax " + "too many commas" );
+            throw new IllegalArgumentException("illegal version range syntax "
+                + "too many commas");
         }
-        Version floor = VersionTable.getVersion( floorCeiling[0] );
-        Version ceiling = "*".equals( floorCeiling[1] ) ? INFINITE_VERSION : Version.parseVersion( floorCeiling[1] );
-        return new VersionRange( openFloor, floor, ceiling, openCeiling );
+        Version floor = VersionTable.getVersion(floorCeiling[0]);
+        Version ceiling = "*".equals(floorCeiling[1]) ? INFINITE_VERSION
+            : Version.parseVersion(floorCeiling[1]);
+        return new VersionRange(openFloor, floor, ceiling, openCeiling);
     }
 
-
     public Version getCeiling()
     {
         return ceiling;
     }
 
-
     public Version getFloor()
     {
         return floor;
     }
 
-
     public boolean isOpenCeiling()
     {
         return openCeiling;
     }
 
-
     public boolean isOpenFloor()
     {
         return openFloor;
     }
 
-
     public boolean isPointVersion()
     {
-        return !openFloor && !openCeiling && floor.equals( ceiling );
+        return !openFloor && !openCeiling && floor.equals(ceiling);
     }
 
-
     /**
      * test a version to see if it falls in the range
      * 
      * @param version
      * @return
      */
-    public boolean contains( Version version )
+    public boolean contains(Version version)
     {
-        if ( version.equals( INFINITE_VERSION ) )
+        if (version.equals(INFINITE_VERSION))
         {
-            return ceiling.equals( INFINITE_VERSION );
+            return ceiling.equals(INFINITE_VERSION);
         }
         else
         {
-            return ( version.compareTo( floor ) > 0 && version.compareTo( ceiling ) < 0 )
-                || ( !openFloor && version.equals( floor ) ) || ( !openCeiling && version.equals( ceiling ) );
+            return (version.compareTo(floor) > 0 && version.compareTo(ceiling) < 0)
+                || (!openFloor && version.equals(floor))
+                || (!openCeiling && version.equals(ceiling));
         }
     }
 
-
     @Override
     public int hashCode()
     {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ( ( ceiling == null ) ? 0 : ceiling.hashCode() );
-        result = prime * result + ( ( floor == null ) ? 0 : floor.hashCode() );
-        result = prime * result + ( openCeiling ? 1231 : 1237 );
-        result = prime * result + ( openFloor ? 1231 : 1237 );
+        result = prime * result + ((ceiling == null) ? 0 : ceiling.hashCode());
+        result = prime * result + ((floor == null) ? 0 : floor.hashCode());
+        result = prime * result + (openCeiling ? 1231 : 1237);
+        result = prime * result + (openFloor ? 1231 : 1237);
         return result;
     }
 
-
     @Override
-    public boolean equals( Object obj )
+    public boolean equals(Object obj)
     {
-        if ( this == obj )
+        if (this == obj)
             return true;
-        if ( obj == null )
+        if (obj == null)
             return false;
-        if ( getClass() != obj.getClass() )
+        if (getClass() != obj.getClass())
             return false;
-        final VersionRange other = ( VersionRange ) obj;
-        if ( ceiling == null )
+        final VersionRange other = (VersionRange) obj;
+        if (ceiling == null)
         {
-            if ( other.ceiling != null )
+            if (other.ceiling != null)
                 return false;
         }
-        else if ( !ceiling.equals( other.ceiling ) )
+        else if (!ceiling.equals(other.ceiling))
             return false;
-        if ( floor == null )
+        if (floor == null)
         {
-            if ( other.floor != null )
+            if (other.floor != null)
                 return false;
         }
-        else if ( !floor.equals( other.floor ) )
+        else if (!floor.equals(other.floor))
             return false;
-        if ( openCeiling != other.openCeiling )
+        if (openCeiling != other.openCeiling)
             return false;
-        if ( openFloor != other.openFloor )
+        if (openFloor != other.openFloor)
             return false;
         return true;
     }
 
-
     @Override
     public String toString()
     {
-        if ( ANY_VERSION.equals( this ) )
+        if (ANY_VERSION.equals(this))
         {
-            return makeString( openFloor, Version.emptyVersion, INFINITE_VERSION, openCeiling );
+            return makeString(openFloor, Version.emptyVersion, INFINITE_VERSION,
+                openCeiling);
         }
-        return makeString( openFloor, floor, ceiling, openCeiling );
+        return makeString(openFloor, floor, ceiling, openCeiling);
     }
 
-
-    private String makeString( boolean openFloor, Version floor, Version ceiling, boolean openCeiling )
+    private String makeString(boolean openFloor, Version floor, Version ceiling,
+        boolean openCeiling)
     {
-        StringBuffer vr = new StringBuffer( 32 );
-        if ( INFINITE_VERSION.equals( ceiling ) )
+        StringBuffer vr = new StringBuffer(32);
+        if (INFINITE_VERSION.equals(ceiling))
         {
-            vr.append( Version.emptyVersion.equals( floor ) ? "0" : floor.toString() );
+            vr.append(Version.emptyVersion.equals(floor) ? "0" : floor.toString());
         }
         else
         {
-            vr.append( openFloor ? "(" : "[" );
-            String floorStr = Version.emptyVersion.equals( floor ) ? "0" : floor.toString();
+            vr.append(openFloor ? "(" : "[");
+            String floorStr = Version.emptyVersion.equals(floor) ? "0" : floor.toString();
             String ceilingStr = ceiling.toString();
-            vr.append( floorStr ).append( "," ).append( ceilingStr );
-            vr.append( openCeiling ? ")" : "]" );
+            vr.append(floorStr).append(",").append(ceilingStr);
+            vr.append(openCeiling ? ")" : "]");
         }
         return vr.toString();
     }
 
-
-    public static VersionRange newInstance( Version pointVersion, VersionRangeBoundingRule lowerBoundRule,
-        VersionRangeBoundingRule upperBoundRule )
+    public static VersionRange newInstance(Version pointVersion,
+        VersionRangeBoundingRule lowerBoundRule, VersionRangeBoundingRule upperBoundRule)
     {
         Version floor = null;
-        switch ( lowerBoundRule )
+        switch (lowerBoundRule)
         {
             case Any:
-                floor = VersionTable.getVersion( 0, 0, 0 );
+                floor = VersionTable.getVersion(0, 0, 0);
                 break;
             case Major:
-                floor = VersionTable.getVersion( pointVersion.getMajor(), 0, 0 );
+                floor = VersionTable.getVersion(pointVersion.getMajor(), 0, 0);
                 break;
             case Minor:
-                floor = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), 0 );
+                floor = VersionTable.getVersion(pointVersion.getMajor(),
+                    pointVersion.getMinor(), 0);
                 break;
             case Micro:
-                floor = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), pointVersion.getMicro() );
+                floor = VersionTable.getVersion(pointVersion.getMajor(),
+                    pointVersion.getMinor(), pointVersion.getMicro());
                 break;
             case Exact:
                 floor = pointVersion;
@@ -278,19 +270,21 @@
 
         Version ceiling = null;
         boolean openCeiling = true;
-        switch ( upperBoundRule )
+        switch (upperBoundRule)
         {
             case Any:
                 ceiling = INFINITE_VERSION;
                 break;
             case Major:
-                ceiling = VersionTable.getVersion( pointVersion.getMajor() + 1, 0, 0 );
+                ceiling = VersionTable.getVersion(pointVersion.getMajor() + 1, 0, 0);
                 break;
             case Minor:
-                ceiling = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor() + 1, 0 );
+                ceiling = VersionTable.getVersion(pointVersion.getMajor(),
+                    pointVersion.getMinor() + 1, 0);
                 break;
             case Micro:
-                ceiling = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), pointVersion.getMicro() + 1 );
+                ceiling = VersionTable.getVersion(pointVersion.getMajor(),
+                    pointVersion.getMinor(), pointVersion.getMicro() + 1);
                 break;
             case Exact:
                 ceiling = pointVersion;
@@ -298,6 +292,6 @@
                 break;
         }
 
-        return new VersionRange( false, floor, ceiling, openCeiling );
+        return new VersionRange(false, floor, ceiling, openCeiling);
     }
 }
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java
index 5ee45da..cb2e236 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.osgi;
 
-
 public enum VersionRangeBoundingRule
 {
     Exact, Micro, Minor, Major, Any
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java
index 0cea80b..0b0b05e 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java
@@ -33,40 +33,49 @@
 public class VersionTable
 {
     private static final WeakHashMap<String, Version> versions = new WeakHashMap<String, Version>();
-    
-    public static Version getVersion(String version) {
-        synchronized( versions ) {
+
+    public static Version getVersion(String version)
+    {
+        synchronized (versions)
+        {
             Version v = versions.get(version);
-            if ( v == null ) {
+            if (v == null)
+            {
                 v = Version.parseVersion(version);
                 versions.put(version, v);
             }
-            
+
             return v;
         }
     }
-    
-    public static Version getVersion(int major, int minor, int micro) {
+
+    public static Version getVersion(int major, int minor, int micro)
+    {
         return getVersion(major, minor, micro, null);
     }
 
-    public static Version getVersion(int major, int minor, int micro, String qualifier) {
+    public static Version getVersion(int major, int minor, int micro, String qualifier)
+    {
         String key;
-        
-        if ( qualifier == null || qualifier.length() == 0 ) {
+
+        if (qualifier == null || qualifier.length() == 0)
+        {
             key = major + "." + minor + "." + micro;
         }
-        else {
-            key = major + "." + minor + "." + micro + "." + qualifier;            
+        else
+        {
+            key = major + "." + minor + "." + micro + "." + qualifier;
         }
-        
-        synchronized( versions ) {
+
+        synchronized (versions)
+        {
             Version v = versions.get(key);
-            if ( v == null ) {
+            if (v == null)
+            {
                 v = new Version(major, minor, micro, qualifier);
                 versions.put(key, v);
             }
-            
+
             return v;
         }
     }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java
index a805611..bd373d1 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java
@@ -41,31 +41,34 @@
 import org.osgi.framework.Constants;
 
 public class BundleForm
-{    
-    public interface Resolver {
+{
+    public interface Resolver
+    {
         URI[] resolve(URI base) throws URISyntaxException;
     }
-    
-    public interface ResolutionContext {
+
+    public interface ResolutionContext
+    {
         Resolver findResolver(URI uri);
     }
-    
-    private static final Resolver NULL_RESOLVER = new Resolver() {
+
+    private static final Resolver NULL_RESOLVER = new Resolver()
+    {
 
         public URI[] resolve(URI base)
         {
             return new URI[] { base };
         }
-        
+
     };
     private static final ResolutionContext NULL_CONTEXT = new ResolutionContext()
-    {      
+    {
         public Resolver findResolver(URI uri)
         {
             return NULL_RESOLVER;
         }
     };
-    
+
     public static class BundleStatus
     {
         private String location;
@@ -73,99 +76,111 @@
         private String version;
         private long id;
         private int status;
-        
+
         public String getLocation()
         {
             return location;
         }
-        
+
         public void setLocation(String location)
         {
             this.location = location;
         }
-        
+
         public String getBundleSymbolicName()
         {
             return bundleSymbolicName;
         }
-        
+
         public void setBundleSymbolicName(String bundleSymbolicName)
         {
             this.bundleSymbolicName = bundleSymbolicName;
         }
-        
+
         public String getVersion()
         {
             return version;
         }
-        
+
         public void setVersion(String version)
         {
             this.version = version;
         }
-        
+
         public long getId()
         {
             return id;
         }
-        
+
         public void setId(long id)
         {
             this.id = id;
         }
-        
+
         public void setStatus(int status)
         {
             this.status = status;
-        }    
-        
-        public int getStatus() {
+        }
+
+        public int getStatus()
+        {
             return status;
         }
 
         public boolean isMatch(BundleStatus n)
         {
-            return bundleSymbolicName.equals( n.bundleSymbolicName ) && version.equals(n.version);
+            return bundleSymbolicName.equals(n.bundleSymbolicName)
+                && version.equals(n.version);
         }
     }
-    
+
     private URI[] bundles;
     private Set<URI> startMap = new HashSet<URI>();
 
-    public BundleForm() {
+    public BundleForm()
+    {
     }
-    
-    public BundleStatus[] resolve(ResolutionContext ctx) throws IOException, URISyntaxException {
-        if ( ctx == null ) {
+
+    public BundleStatus[] resolve(ResolutionContext ctx) throws IOException,
+        URISyntaxException
+    {
+        if (ctx == null)
+        {
             ctx = NULL_CONTEXT;
         }
-        
+
         ArrayList<BundleStatus> ret = new ArrayList<BundleStatus>(bundles.length);
-        
-        for ( int i = 0; i < bundles.length; i++ ) {
+
+        for (int i = 0; i < bundles.length; i++)
+        {
             Resolver resolver = ctx.findResolver(bundles[i]);
-            if ( resolver == null ) {
+            if (resolver == null)
+            {
                 resolver = NULL_RESOLVER;
             }
             URI[] resolved = resolver.resolve(bundles[i]);
-            for ( URI uri : resolved ) {
+            for (URI uri : resolved)
+            {
                 BundleStatus bundle = toBundle(uri, isStarted(bundles[i]));
-                if ( bundle == null ) {
+                if (bundle == null)
+                {
                     throw new IllegalStateException("Failed to read bundle " + uri);
                 }
-                ret.add( bundle );
+                ret.add(bundle);
             }
         }
-        
-        return ret.toArray(new BundleStatus[ret.size()] );
+
+        return ret.toArray(new BundleStatus[ret.size()]);
 
     }
-    
+
     private BundleStatus toBundle(URI uri, boolean started) throws IOException
     {
-        try {
+        try
+        {
             Manifest mf = findManifest(uri);
-            if ( mf == null ) return null;
+            if (mf == null)
+                return null;
             Attributes attr = mf.getMainAttributes();
             String bsn = attr.getValue(Constants.BUNDLE_SYMBOLICNAME);
             String ver = attr.getValue(Constants.BUNDLE_VERSION);
@@ -176,7 +191,8 @@
             st.setStatus(started ? Bundle.ACTIVE : Bundle.INSTALLED);
             return st;
         }
-        catch (IllegalArgumentException e) {
+        catch (IllegalArgumentException e)
+        {
             throw new IllegalArgumentException("Invalid uri " + uri, e);
         }
     }
@@ -185,71 +201,90 @@
     {
         Manifest mf = null;
 
-        try {
+        try
+        {
             File f = new File(uri);
-            if ( f.isDirectory() ) {
-                f = new File(f, "META-INF/MANIFEST.MF" );
-                if ( f.isFile() ) {
+            if (f.isDirectory())
+            {
+                f = new File(f, "META-INF/MANIFEST.MF");
+                if (f.isFile())
+                {
                     FileInputStream fin = new FileInputStream(f);
-                    try {
+                    try
+                    {
                         mf = new Manifest(fin);
                     }
-                    finally { 
+                    finally
+                    {
                         fin.close();
                     }
                 }
             }
         }
-        catch (IllegalArgumentException e) {
+        catch (IllegalArgumentException e)
+        {
             // fine
         }
-        
-        if ( mf == null) {
+
+        if (mf == null)
+        {
             InputStream in = uri.toURL().openStream();
-            try {
+            try
+            {
                 JarInputStream jin = new JarInputStream(in);
                 mf = jin.getManifest();
-                if ( mf == null ) {
-                    for(;;) {
+                if (mf == null)
+                {
+                    for (;;)
+                    {
                         JarEntry entry = jin.getNextJarEntry();
-                        if ( entry == null ) break;
-                        if ( "META-INF/MANIFEST.MF".equals(entry.getName()) ) {
+                        if (entry == null)
+                            break;
+                        if ("META-INF/MANIFEST.MF".equals(entry.getName()))
+                        {
                             mf = new Manifest(jin);
                             break;
                         }
                     }
                 }
-                
+
             }
-            finally {
+            finally
+            {
                 in.close();
             }
         }
         return mf;
     }
 
-    public static BundleForm create(URL formURL) throws IOException, URISyntaxException {
+    public static BundleForm create(URL formURL) throws IOException, URISyntaxException
+    {
         InputStream in = formURL.openStream();
-        try {
+        try
+        {
             BundleForm f = new BundleForm();
             BufferedReader r = new BufferedReader(new InputStreamReader(in));
             LinkedList<URI> locs = new LinkedList<URI>();
-            for(;;) {
+            for (;;)
+            {
                 String l = r.readLine();
-                if ( l == null ) break;
+                if (l == null)
+                    break;
                 l = l.trim();
-                if ( !l.startsWith( "#" ) ) {
+                if (!l.startsWith("#"))
+                {
                     URI uri = URI.create(l);
                     String status = uri.getScheme();
                     uri = URI.create(uri.getSchemeSpecificPart());
-                    locs.add( uri );
-                    f.setStarted(uri, "start".equalsIgnoreCase(status) );
+                    locs.add(uri);
+                    f.setStarted(uri, "start".equalsIgnoreCase(status));
                 }
             }
             f.setBundles(locs.toArray(new URI[locs.size()]));
             return f;
         }
-        finally {
+        finally
+        {
             try
             {
                 in.close();
@@ -262,10 +297,11 @@
         }
     }
 
-    public void setBundles(URI[] bundles) {
+    public void setBundles(URI[] bundles)
+    {
         this.bundles = bundles;
     }
-    
+
     public URI[] getBundles()
     {
         return bundles;
@@ -275,13 +311,16 @@
     {
         return startMap.contains(uri);
     }
-    
-    public void setStarted(URI uri, boolean started) {
-        if ( started ) {
+
+    public void setStarted(URI uri, boolean started)
+    {
+        if (started)
+        {
             startMap.add(uri);
         }
-        else {
+        else
+        {
             startMap.remove(uri);
         }
-    }    
+    }
 }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java
index 8f9daa3..fd9a2c2 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -43,7 +42,6 @@
 import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
 import static org.apache.felix.sigil.common.runtime.Runtime.ADDRESS_PROPERTY;
 
-
 /**
  * @author dave
  *
@@ -54,36 +52,37 @@
     private DataInputStream in;
     private DataOutputStream out;
 
-
     public Client()
     {
     }
-    
+
     public void connect(Properties props) throws IOException
     {
-        String v = props.getProperty( ADDRESS_PROPERTY );
-        InetAddress address = v == null ? null : InetAddress.getByName( v );
-        int port = Integer.parseInt( props.getProperty( PORT_PROPERTY, "0" ) );
-        
-        if ( port < 1 ) {
-            throw new IOException( "Missing or invalid port" );
+        String v = props.getProperty(ADDRESS_PROPERTY);
+        InetAddress address = v == null ? null : InetAddress.getByName(v);
+        int port = Integer.parseInt(props.getProperty(PORT_PROPERTY, "0"));
+
+        if (port < 1)
+        {
+            throw new IOException("Missing or invalid port");
         }
-        
+
         InetSocketAddress endpoint = new InetSocketAddress(address, port);
-        
+
         socket = new Socket();
-        socket.connect( endpoint );
-        
-        Main.log( "Connected to " + endpoint );
-        
-        in = new DataInputStream( socket.getInputStream() );
-        out = new DataOutputStream( socket.getOutputStream() );        
+        socket.connect(endpoint);
+
+        Main.log("Connected to " + endpoint);
+
+        in = new DataInputStream(socket.getInputStream());
+        out = new DataOutputStream(socket.getOutputStream());
     }
 
-    public boolean isConnected() {
+    public boolean isConnected()
+    {
         return socket != null;
     }
-    
+
     public void disconnect() throws IOException
     {
         socket.close();
@@ -92,148 +91,174 @@
         out = null;
     }
 
-    public void apply(BundleForm.BundleStatus[] newStatus) throws IOException, BundleException {
+    public void apply(BundleForm.BundleStatus[] newStatus) throws IOException,
+        BundleException
+    {
         BundleStatus[] currentStatus = status();
-        
+
         stopOldBundles(currentStatus, newStatus);
-        
+
         boolean change = uninstallOldBundles(currentStatus, newStatus);
         change |= installNewBundles(currentStatus, newStatus);
-        
-        if ( change )
+
+        if (change)
             refresh();
-        
+
         startNewBundles(newStatus);
     }
 
     public void refresh() throws IOException, BundleException
     {
-        if ( socket == null ) throw new IllegalStateException( "Not connected" );
-        new RefreshAction( in, out ).client();
+        if (socket == null)
+            throw new IllegalStateException("Not connected");
+        new RefreshAction(in, out).client();
     }
 
-    public long install( String url ) throws IOException, BundleException
+    public long install(String url) throws IOException, BundleException
     {
-        if ( socket == null ) throw new IllegalStateException( "Not connected" );
-        return new InstallAction( in, out ).client( url );
+        if (socket == null)
+            throw new IllegalStateException("Not connected");
+        return new InstallAction(in, out).client(url);
     }
 
-
-    public void start( long bundle ) throws IOException, BundleException
+    public void start(long bundle) throws IOException, BundleException
     {
-        if ( socket == null ) throw new IllegalStateException( "Not connected" );
-        new StartAction( in, out ).client( bundle );
+        if (socket == null)
+            throw new IllegalStateException("Not connected");
+        new StartAction(in, out).client(bundle);
     }
 
-
-    public void stop( long bundle ) throws IOException, BundleException
+    public void stop(long bundle) throws IOException, BundleException
     {
-        if ( socket == null ) throw new IllegalStateException( "Not connected" );
-        new StopAction( in, out ).client( bundle );
+        if (socket == null)
+            throw new IllegalStateException("Not connected");
+        new StopAction(in, out).client(bundle);
     }
 
-
-    public void uninstall( long bundle ) throws IOException, BundleException
+    public void uninstall(long bundle) throws IOException, BundleException
     {
-        if ( socket == null ) throw new IllegalStateException( "Not connected" );
-        new UninstallAction( in, out ).client( bundle );
+        if (socket == null)
+            throw new IllegalStateException("Not connected");
+        new UninstallAction(in, out).client(bundle);
     }
 
-
-    public void update( long bundle ) throws IOException, BundleException
+    public void update(long bundle) throws IOException, BundleException
     {
-        if ( socket == null ) throw new IllegalStateException( "Not connected" );
+        if (socket == null)
+            throw new IllegalStateException("Not connected");
         Update update = new UpdateAction.Update(bundle, null);
-        new UpdateAction( in, out ).client(update);
+        new UpdateAction(in, out).client(update);
     }
 
-
-    public void update( long bundle, String url ) throws IOException, BundleException
+    public void update(long bundle, String url) throws IOException, BundleException
     {
-        if ( socket == null ) throw new IllegalStateException( "Not connected" );
+        if (socket == null)
+            throw new IllegalStateException("Not connected");
         Update update = new UpdateAction.Update(bundle, url);
-        new UpdateAction( in, out ).client(update);
+        new UpdateAction(in, out).client(update);
     }
 
-
     public BundleStatus[] status() throws IOException, BundleException
     {
-        if ( socket == null ) throw new IllegalStateException( "Not connected" );
-        return new StatusAction( in, out ).client();
+        if (socket == null)
+            throw new IllegalStateException("Not connected");
+        return new StatusAction(in, out).client();
     }
-    
-    private boolean installNewBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+
+    private boolean installNewBundles(BundleStatus[] status, BundleStatus[] newStatus)
+        throws IOException, BundleException
     {
         boolean change = false;
-        for (BundleStatus n : newStatus) {
+        for (BundleStatus n : newStatus)
+        {
             boolean found = false;
-            for ( BundleStatus o : status ) {
-                if ( o.isMatch(n) ) {
+            for (BundleStatus o : status)
+            {
+                if (o.isMatch(n))
+                {
                     update(o.getId(), n.getLocation());
                     found = true;
                     change = true;
                     break;
                 }
             }
-            
-            if ( !found ) {
+
+            if (!found)
+            {
                 install(n.getLocation());
                 change = true;
             }
         }
-        
+
         return change;
     }
 
-    private void startNewBundles(BundleStatus[] newStatus) throws IOException, BundleException
+    private void startNewBundles(BundleStatus[] newStatus) throws IOException,
+        BundleException
     {
         BundleStatus[] status = status();
-        for (BundleStatus n : newStatus) {
-            if ( n.getStatus() == Bundle.ACTIVE ) {
-                for ( BundleStatus o : status ) {
-                    if ( o.isMatch(n) ) {
+        for (BundleStatus n : newStatus)
+        {
+            if (n.getStatus() == Bundle.ACTIVE)
+            {
+                for (BundleStatus o : status)
+                {
+                    if (o.isMatch(n))
+                    {
                         start(o.getId());
                     }
                 }
-            }            
+            }
         }
     }
 
-    private void stopOldBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+    private void stopOldBundles(BundleStatus[] status, BundleStatus[] newStatus)
+        throws IOException, BundleException
     {
-        for (BundleStatus n : newStatus) {
-            if ( n.getStatus() == Bundle.INSTALLED ) {
-                for ( BundleStatus o : status ) {
-                    if ( o.getId() != 0 ) {
-                        if ( o.isMatch(n) ) {
+        for (BundleStatus n : newStatus)
+        {
+            if (n.getStatus() == Bundle.INSTALLED)
+            {
+                for (BundleStatus o : status)
+                {
+                    if (o.getId() != 0)
+                    {
+                        if (o.isMatch(n))
+                        {
                             stop(o.getId());
-                        }                        
+                        }
                     }
                 }
-            }            
+            }
         }
     }
 
-    private boolean uninstallOldBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+    private boolean uninstallOldBundles(BundleStatus[] status, BundleStatus[] newStatus)
+        throws IOException, BundleException
     {
         boolean change = false;
-        for ( BundleStatus o : status ) {
-            if ( o.getId() != 0 ) {
+        for (BundleStatus o : status)
+        {
+            if (o.getId() != 0)
+            {
                 boolean found = false;
-                
-                for (BundleStatus n : newStatus) {
-                    if ( o.isMatch(n) ) {
+
+                for (BundleStatus n : newStatus)
+                {
+                    if (o.isMatch(n))
+                    {
                         found = true;
                         break;
                     }
                 }
-                
-                if ( !found ) {
+
+                if (!found)
+                {
                     change = true;
                     uninstall(o.getId());
                 }
             }
         }
         return change;
-    }    
+    }
 }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
index e0a1362..34572f5 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime;
 
-
 import static org.apache.felix.sigil.common.runtime.Runtime.ADDRESS_PROPERTY;
 import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
 
@@ -42,89 +41,88 @@
 import org.osgi.framework.launch.Framework;
 import org.osgi.framework.launch.FrameworkFactory;
 
-
 public class Main
 {
     private static final String COMMAND_LINE_SYNTAX = "java -jar org.apache.felix.sigil.common.runtime";
 
     private static Framework framework;
     private static final Options options;
-    
+
     private static boolean verbose = false;
 
     static
     {
         options = new Options();
-        options.addOption( "?", "help", false, "Print help for the Sigil launcher" );
-        options.addOption( "p", "port", true, "Port to launch server on (0 implies auto allocate) [default 0]" );
-        options.addOption( "a", "address", true, "Address to bind server to [default all]" );
-        options.addOption( "c", "clean", false, "Clean bundle cache directory on init" );
-        options.addOption( "s", "startLevel", true, "Start level for framework" );
-        options.addOption( "v", "verbose", false, "Verbose output" );
+        options.addOption("?", "help", false, "Print help for the Sigil launcher");
+        options.addOption("p", "port", true,
+            "Port to launch server on (0 implies auto allocate) [default 0]");
+        options.addOption("a", "address", true, "Address to bind server to [default all]");
+        options.addOption("c", "clean", false, "Clean bundle cache directory on init");
+        options.addOption("s", "startLevel", true, "Start level for framework");
+        options.addOption("v", "verbose", false, "Verbose output");
     }
 
-
-    public static void main( String[] args ) throws Exception
+    public static void main(String[] args) throws Exception
     {
         FrameworkFactory factory = getFrameworkFactory();
 
         try
         {
             Parser parser = new PosixParser();
-            CommandLine cl = parser.parse( options, args );
+            CommandLine cl = parser.parse(options, args);
 
-            if ( cl.hasOption( '?' ) )
+            if (cl.hasOption('?'))
             {
                 printHelp();
             }
             else
             {
                 verbose = cl.hasOption('v');
-                
-                Map<String, String> config = buildConfig( cl );
 
-                framework = factory.newFramework( config );
+                Map<String, String> config = buildConfig(cl);
+
+                framework = factory.newFramework(config);
                 framework.init();
                 framework.start();
 
-                Server server = launch( cl );
+                Server server = launch(cl);
 
-                framework.waitForStop( 0 );
+                framework.waitForStop(0);
 
-                if ( server != null )
+                if (server != null)
                 {
                     server.stop();
                 }
             }
         }
-        catch ( NoSuchElementException e )
+        catch (NoSuchElementException e)
         {
-            System.err.println( "No " + FrameworkFactory.class.getName() + " found on classpath" );
-            System.exit( 1 );
+            System.err.println("No " + FrameworkFactory.class.getName()
+                + " found on classpath");
+            System.exit(1);
         }
-        catch ( InterruptedException e )
+        catch (InterruptedException e)
         {
-            System.err.println( "Interrupted prior to framework stop" );
-            System.exit( 1 );
+            System.err.println("Interrupted prior to framework stop");
+            System.exit(1);
         }
-        catch ( ParseException e )
+        catch (ParseException e)
         {
             printHelp();
-            System.exit( 1 );
+            System.exit(1);
         }
-        catch ( BundleException e )
+        catch (BundleException e)
         {
             e.printStackTrace();
-            System.exit( 1 );
+            System.exit(1);
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
             e.printStackTrace();
-            System.exit( 1 );
+            System.exit(1);
         }
     }
 
-
     /**
      * Simple method to parse META-INF/services file for framework factory.
      * Currently, it assumes the first non-commented line is the class name
@@ -135,65 +133,64 @@
     private static FrameworkFactory getFrameworkFactory() throws Exception
     {
         URL url = Main.class.getClassLoader().getResource(
-            "META-INF/services/org.osgi.framework.launch.FrameworkFactory" );
-        if ( url != null )
+            "META-INF/services/org.osgi.framework.launch.FrameworkFactory");
+        if (url != null)
         {
-            BufferedReader br = new BufferedReader( new InputStreamReader( url.openStream() ) );
+            BufferedReader br = new BufferedReader(
+                new InputStreamReader(url.openStream()));
             try
             {
-                for ( String s = br.readLine(); s != null; s = br.readLine() )
+                for (String s = br.readLine(); s != null; s = br.readLine())
                 {
                     s = s.trim();
                     // Try to load first non-empty, non-commented line.
-                    if ( ( s.length() > 0 ) && ( s.charAt( 0 ) != '#' ) )
+                    if ((s.length() > 0) && (s.charAt(0) != '#'))
                     {
-                        return ( FrameworkFactory ) Class.forName( s ).newInstance();
+                        return (FrameworkFactory) Class.forName(s).newInstance();
                     }
                 }
             }
             finally
             {
-                if ( br != null )
+                if (br != null)
                     br.close();
             }
         }
 
-        throw new Exception( "Could not find framework factory." );
+        throw new Exception("Could not find framework factory.");
     }
 
-
-    private static Map<String, String> buildConfig( CommandLine cl )
+    private static Map<String, String> buildConfig(CommandLine cl)
     {
         HashMap<String, String> config = new HashMap<String, String>();
-        if ( cl.hasOption( 'c' ))
-            config.put(  "org.osgi.framework.storage.clean", "onFirstInit" );
-        
-        if ( cl.hasOption( 's' ) )
-            config.put( "org.osgi.framework.startlevel.beginning", cl.getOptionValue( 's' ) );
-        
+        if (cl.hasOption('c'))
+            config.put("org.osgi.framework.storage.clean", "onFirstInit");
+
+        if (cl.hasOption('s'))
+            config.put("org.osgi.framework.startlevel.beginning", cl.getOptionValue('s'));
+
         return config;
     }
 
-
-    private static Server launch( CommandLine line ) throws IOException
+    private static Server launch(CommandLine line) throws IOException
     {
-        Server server = new Server( framework );
+        Server server = new Server(framework);
         Properties props = new Properties();
-        props.put( ADDRESS_PROPERTY, line.getOptionValue( 'a' ) );
-        props.put( PORT_PROPERTY, line.getOptionValue( 'p' ) );
-        server.start( props );
+        props.put(ADDRESS_PROPERTY, line.getOptionValue('a'));
+        props.put(PORT_PROPERTY, line.getOptionValue('p'));
+        server.start(props);
         return server;
     }
 
-
     private static void printHelp()
     {
         HelpFormatter f = new HelpFormatter();
-        f.printHelp( COMMAND_LINE_SYNTAX, options );
+        f.printHelp(COMMAND_LINE_SYNTAX, options);
     }
-    
-    public static void log(String msg) {
-        if ( verbose )
-            System.out.println( msg );
+
+    public static void log(String msg)
+    {
+        if (verbose)
+            System.out.println(msg);
     }
 }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java
index 6d37887..4ee4357 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.EOFException;
@@ -47,7 +46,6 @@
 import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
 import static org.apache.felix.sigil.common.runtime.io.Constants.*;
 
-
 /**
  * @author dave
  *
@@ -60,54 +58,52 @@
 
     private AtomicBoolean stopped = new AtomicBoolean();
 
-
-    public Server( Framework fw )
+    public Server(Framework fw)
     {
         this.fw = fw;
     }
 
-
-    public void start( Properties props ) throws IOException
+    public void start(Properties props) throws IOException
     {
         final ServerSocket socket = new ServerSocket();
-        
-        String v = props.getProperty( ADDRESS_PROPERTY );
-        InetAddress address = v == null ? null : InetAddress.getByName( v );
-        int port = Integer.parseInt( props.getProperty( PORT_PROPERTY, "0" ) );
-        
-        InetSocketAddress socketAddress = new InetSocketAddress(address, port);        
-        socket.bind( socketAddress );
 
-        Main.log( "Started server listening on " + socket.getLocalSocketAddress() + ":" + socket.getLocalPort() );
-        
-        accept = new Thread( new Runnable()
+        String v = props.getProperty(ADDRESS_PROPERTY);
+        InetAddress address = v == null ? null : InetAddress.getByName(v);
+        int port = Integer.parseInt(props.getProperty(PORT_PROPERTY, "0"));
+
+        InetSocketAddress socketAddress = new InetSocketAddress(address, port);
+        socket.bind(socketAddress);
+
+        Main.log("Started server listening on " + socket.getLocalSocketAddress() + ":"
+            + socket.getLocalPort());
+
+        accept = new Thread(new Runnable()
         {
             public void run()
             {
-                while ( !stopped.get() )
+                while (!stopped.get())
                 {
                     try
                     {
-                        read.execute( new Reader( socket.accept() ) );
+                        read.execute(new Reader(socket.accept()));
                     }
-                    catch ( IOException e )
+                    catch (IOException e)
                     {
                         // TODO Auto-generated catch block
                         e.printStackTrace();
                     }
                 }
             }
-        } );
-        
-        accept.start();
-        
-        Main.log( "Started thread!" );
-    }
+        });
 
+        accept.start();
+
+        Main.log("Started thread!");
+    }
 
     public void stop()
     {
-        stopped.set( true );
+        stopped.set(true);
         accept.interrupt();
         accept = null;
     }
@@ -117,81 +113,83 @@
 
         private final Socket socket;
 
-
         /**
          * @param accept
          */
-        public Reader( Socket socket )
+        public Reader(Socket socket)
         {
             this.socket = socket;
         }
 
-
         /* (non-Javadoc)
          * @see java.lang.Runnable#run()
          */
         public void run()
         {
-            Main.log( "Accepted " + socket.getInetAddress() + ":" + socket.getLocalPort() );
-            
+            Main.log("Accepted " + socket.getInetAddress() + ":" + socket.getLocalPort());
+
             try
             {
-                DataInputStream in = new DataInputStream( socket.getInputStream() );
-                DataOutputStream out = new DataOutputStream( socket.getOutputStream() );
-                
-                while ( !stopped.get() )
+                DataInputStream in = new DataInputStream(socket.getInputStream());
+                DataOutputStream out = new DataOutputStream(socket.getOutputStream());
+
+                while (!stopped.get())
                 {
                     int action = in.readInt();
-                    
+
                     Action<?, ?> task = null;
-                    
-                    switch ( action )
+
+                    switch (action)
                     {
                         case INSTALL:
-                            task = new InstallAction( in, out );
+                            task = new InstallAction(in, out);
                             break;
                         case START:
-                            task = new StartAction( in, out );
+                            task = new StartAction(in, out);
                             break;
                         case STOP:
-                            task = new StopAction( in, out );
+                            task = new StopAction(in, out);
                             break;
                         case UNINSTALL:
-                            task = new UninstallAction( in, out );
+                            task = new UninstallAction(in, out);
                             break;
                         case UPDATE:
-                            task = new UpdateAction( in, out );
+                            task = new UpdateAction(in, out);
                             break;
                         case STATUS:
-                            task = new StatusAction( in, out );
+                            task = new StatusAction(in, out);
                             break;
                         case REFRESH:
                             task = new RefreshAction(in, out);
                             break;
                     }
-                    
-                    if ( task == null ) {
-                        Main.log( "Invalid action " + action );
+
+                    if (task == null)
+                    {
+                        Main.log("Invalid action " + action);
                     }
-                    else {
-                        task.server( fw );
+                    else
+                    {
+                        task.server(fw);
                     }
                 }
             }
-            catch ( EOFException e ) {
+            catch (EOFException e)
+            {
                 // fine
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
-            finally {
+            finally
+            {
                 try
                 {
                     socket.close();
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java
index 32483c3..e1ce866 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java
@@ -53,8 +53,9 @@
      */
     public AlreadySelectedException(OptionGroup group, Option option)
     {
-        this("The option '" + option.getKey() + "' was specified but an option from this group "
-                + "has already been selected: '" + group.getSelected() + "'");
+        this("The option '" + option.getKey()
+            + "' was specified but an option from this group "
+            + "has already been selected: '" + group.getSelected() + "'");
         this.group = group;
         this.option = option;
     }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java
index 2737285..55bf80f 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java
@@ -39,7 +39,8 @@
      * when an non option is found.
      * @return The <code>arguments</code> String array.
      */
-    protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+    protected String[] flatten(Options options, String[] arguments,
+        boolean stopAtNonOption)
     {
         // just echo the arguments
         return arguments;
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java
index 02d9dbc..912db47 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java
@@ -89,11 +89,14 @@
      */
     public Object getOptionObject(String opt)
     {
-        try {
+        try
+        {
             return getParsedOptionValue(opt);
-        } catch(ParseException pe) {
-            System.err.println("Exception found converting " + opt + " to desired type: " + 
-                pe.getMessage() );
+        }
+        catch (ParseException pe)
+        {
+            System.err.println("Exception found converting " + opt + " to desired type: "
+                + pe.getMessage());
             return null;
         }
     }
@@ -106,8 +109,7 @@
      * @throws ParseException if there are problems turning the option value into the desired type
      * @see PatternOptionBuilder
      */
-    public Object getParsedOptionValue(String opt)
-    throws ParseException
+    public Object getParsedOptionValue(String opt) throws ParseException
     {
         String res = getOptionValue(opt);
 
@@ -119,7 +121,7 @@
 
         Object type = option.getType();
 
-        return (res == null)        ? null : TypeHandler.createValue(res, type);
+        return (res == null) ? null : TypeHandler.createValue(res, type);
     }
 
     /**
@@ -179,7 +181,8 @@
             }
         }
 
-        return values.isEmpty() ? null : (String[]) values.toArray(new String[values.size()]);
+        return values.isEmpty() ? null
+            : (String[]) values.toArray(new String[values.size()]);
     }
 
     /**
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java
index 237d637..cdfa8c2 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java
@@ -70,7 +70,8 @@
      * @throws ParseException if there are any problems encountered
      * while parsing the command line tokens.
      */
-    CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException;
+    CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption)
+        throws ParseException;
 
     /**
      * Parse the arguments according to the specified options and
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java
index c53cacf..e130aa9 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java
@@ -46,7 +46,8 @@
      *                        a non option has been encountered
      * @return a String array of the flattened arguments
      */
-    protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+    protected String[] flatten(Options options, String[] arguments,
+        boolean stopAtNonOption)
     {
         List tokens = new ArrayList();
 
@@ -75,7 +76,8 @@
                 }
                 else
                 {
-                    if (opt.indexOf('=') != -1 && options.hasOption(opt.substring(0, opt.indexOf('='))))
+                    if (opt.indexOf('=') != -1
+                        && options.hasOption(opt.substring(0, opt.indexOf('='))))
                     {
                         // the format is --foo=value or -foo=value
                         tokens.add(arg.substring(0, arg.indexOf('='))); // --foo
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java
index 46d9bf0..bb0cc2e 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java
@@ -359,7 +359,8 @@
      * @param options the Options instance
      * @param footer the banner to display at the end of the help
      */
-    public void printHelp(String cmdLineSyntax, String header, Options options, String footer)
+    public void printHelp(String cmdLineSyntax, String header, Options options,
+        String footer)
     {
         printHelp(cmdLineSyntax, header, options, footer, false);
     }
@@ -376,7 +377,8 @@
      * @param autoUsage whether to print an automatically generated
      * usage statement
      */
-    public void printHelp(String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
+    public void printHelp(String cmdLineSyntax, String header, Options options,
+        String footer, boolean autoUsage)
     {
         printHelp(defaultWidth, cmdLineSyntax, header, options, footer, autoUsage);
     }
@@ -392,7 +394,8 @@
      * @param options the Options instance
      * @param footer the banner to display at the end of the help
      */
-    public void printHelp(int width, String cmdLineSyntax, String header, Options options, String footer)
+    public void printHelp(int width, String cmdLineSyntax, String header,
+        Options options, String footer)
     {
         printHelp(width, cmdLineSyntax, header, options, footer, false);
     }
@@ -411,11 +414,12 @@
      * usage statement
      */
     public void printHelp(int width, String cmdLineSyntax, String header,
-                          Options options, String footer, boolean autoUsage)
+        Options options, String footer, boolean autoUsage)
     {
         PrintWriter pw = new PrintWriter(System.out);
 
-        printHelp(pw, width, cmdLineSyntax, header, options, defaultLeftPad, defaultDescPad, footer, autoUsage);
+        printHelp(pw, width, cmdLineSyntax, header, options, defaultLeftPad,
+            defaultDescPad, footer, autoUsage);
         pw.flush();
     }
 
@@ -436,14 +440,13 @@
      *
      * @throws IllegalStateException if there is no room to print a line
      */
-    public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, 
-                          String header, Options options, int leftPad, 
-                          int descPad, String footer)
+    public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header,
+        Options options, int leftPad, int descPad, String footer)
     {
-        printHelp(pw, width, cmdLineSyntax, header, options, leftPad, descPad, footer, false);
+        printHelp(pw, width, cmdLineSyntax, header, options, leftPad, descPad, footer,
+            false);
     }
 
-
     /**
      * Print the help for <code>options</code> with the specified
      * command line syntax.
@@ -463,9 +466,8 @@
      *
      * @throws IllegalStateException if there is no room to print a line
      */
-    public void printHelp(PrintWriter pw, int width, String cmdLineSyntax,
-                          String header, Options options, int leftPad,
-                          int descPad, String footer, boolean autoUsage)
+    public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header,
+        Options options, int leftPad, int descPad, String footer, boolean autoUsage)
     {
         if ((cmdLineSyntax == null) || (cmdLineSyntax.length() == 0))
         {
@@ -534,7 +536,6 @@
                     // add the group to the processed list
                     processedGroups.add(group);
 
-
                     // add the usage clause
                     appendOptionGroup(buff, group);
                 }
@@ -555,7 +556,6 @@
             }
         }
 
-
         // call printWrapped
         printWrapped(pw, width, buff.toString().indexOf(' ') + 1, buff.toString());
     }
@@ -602,7 +602,8 @@
      * @param option the Option to append
      * @param required whether the Option is required or not
      */
-    private static void appendOption(final StringBuffer buff, final Option option, final boolean required)
+    private static void appendOption(final StringBuffer buff, final Option option,
+        final boolean required)
     {
         if (!required)
         {
@@ -643,7 +644,8 @@
     {
         int argPos = cmdLineSyntax.indexOf(' ') + 1;
 
-        printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos, defaultSyntaxPrefix + cmdLineSyntax);
+        printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos,
+            defaultSyntaxPrefix + cmdLineSyntax);
     }
 
     /**
@@ -658,8 +660,8 @@
      * @param descPad the number of characters of padding to be prefixed
      * to each description line
      */
-    public void printOptions(PrintWriter pw, int width, Options options, 
-                             int leftPad, int descPad)
+    public void printOptions(PrintWriter pw, int width, Options options, int leftPad,
+        int descPad)
     {
         StringBuffer sb = new StringBuffer();
 
@@ -711,7 +713,8 @@
      *
      * @return the StringBuffer with the rendered Options contents.
      */
-    protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad)
+    protected StringBuffer renderOptions(StringBuffer sb, int width, Options options,
+        int leftPad, int descPad)
     {
         final String lpad = createPadding(leftPad);
         final String dpad = createPadding(descPad);
@@ -735,7 +738,8 @@
 
             if (option.getOpt() == null)
             {
-                optBuf.append(lpad).append("   " + defaultLongOptPrefix).append(option.getLongOpt());
+                optBuf.append(lpad).append("   " + defaultLongOptPrefix).append(
+                    option.getLongOpt());
             }
             else
             {
@@ -743,7 +747,8 @@
 
                 if (option.hasLongOpt())
                 {
-                    optBuf.append(',').append(defaultLongOptPrefix).append(option.getLongOpt());
+                    optBuf.append(',').append(defaultLongOptPrefix).append(
+                        option.getLongOpt());
                 }
             }
 
@@ -806,8 +811,8 @@
      *
      * @return the StringBuffer with the rendered Options contents.
      */
-    protected StringBuffer renderWrappedText(StringBuffer sb, int width, 
-                                             int nextLineTabStop, String text)
+    protected StringBuffer renderWrappedText(StringBuffer sb, int width,
+        int nextLineTabStop, String text)
     {
         int pos = findWrapPos(text, width, 0);
 
@@ -840,8 +845,8 @@
 
                 return sb;
             }
-            
-            if ( (text.length() > width) && (pos == nextLineTabStop - 1) ) 
+
+            if ((text.length() > width) && (pos == nextLineTabStop - 1))
             {
                 pos = width;
             }
@@ -869,7 +874,7 @@
 
         // the line ends before the max wrap pos or a new line char found
         if (((pos = text.indexOf('\n', startPos)) != -1 && pos <= width)
-                || ((pos = text.indexOf('\t', startPos)) != -1 && pos <= width))
+            || ((pos = text.indexOf('\t', startPos)) != -1 && pos <= width))
         {
             return pos + 1;
         }
@@ -878,14 +883,13 @@
             return -1;
         }
 
-
         // look for the last whitespace character before startPos+width
         pos = startPos + width;
 
         char c;
 
-        while ((pos >= startPos) && ((c = text.charAt(pos)) != ' ')
-                && (c != '\n') && (c != '\r'))
+        while ((pos >= startPos) && ((c = text.charAt(pos)) != ' ') && (c != '\n')
+            && (c != '\r'))
         {
             --pos;
         }
@@ -895,13 +899,13 @@
         {
             return pos;
         }
-        
+
         // must look for the first whitespace chearacter after startPos 
         // + width
         pos = startPos + width;
 
-        while ((pos <= text.length()) && ((c = text.charAt(pos)) != ' ')
-               && (c != '\n') && (c != '\r'))
+        while ((pos <= text.length()) && ((c = text.charAt(pos)) != ' ') && (c != '\n')
+            && (c != '\r'))
         {
             ++pos;
         }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java
index 8fd69a7..acf66e3 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java
@@ -116,8 +116,7 @@
      * @throws IllegalArgumentException if there are any non valid
      * Option characters in <code>opt</code>.
      */
-    public Option(String opt, String longOpt, boolean hasArg, String description)
-           throws IllegalArgumentException
+    public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException
     {
         // ensure that the option is valid
         OptionValidator.validateOption(opt);
@@ -529,7 +528,8 @@
      */
     public String[] getValues()
     {
-        return hasNoValues() ? null : (String[]) values.toArray(new String[values.size()]);
+        return hasNoValues() ? null
+            : (String[]) values.toArray(new String[values.size()]);
     }
 
     /**
@@ -603,7 +603,6 @@
 
         Option option = (Option) o;
 
-
         if (opt != null ? !opt.equals(option.opt) : option.opt != null)
         {
             return false;
@@ -644,7 +643,8 @@
         }
         catch (CloneNotSupportedException cnse)
         {
-            throw new RuntimeException("A CloneNotSupportedException was thrown: " + cnse.getMessage());
+            throw new RuntimeException("A CloneNotSupportedException was thrown: "
+                + cnse.getMessage());
         }
     }
 
@@ -667,7 +667,8 @@
      */
     public boolean addValue(String value)
     {
-        throw new UnsupportedOperationException("The addValue method is not intended for client use. "
+        throw new UnsupportedOperationException(
+            "The addValue method is not intended for client use. "
                 + "Subclasses should use the addValueForProcessing method instead. ");
     }
 
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java
index 7056769..2deef51 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java
@@ -77,7 +77,6 @@
         required = false;
         numberOfArgs = Option.UNINITIALIZED;
 
-
         // PMM 9/6/02 - these were missing
         optionalArg = false;
         valuesep = (char) 0;
@@ -346,7 +345,8 @@
     public static Option create(String opt) throws IllegalArgumentException
     {
         Option option = null;
-        try {
+        try
+        {
             // create the option
             option = new Option(opt, description);
 
@@ -358,7 +358,9 @@
             option.setType(type);
             option.setValueSeparator(valuesep);
             option.setArgName(argName);
-        } finally {
+        }
+        finally
+        {
             // reset the OptionBuilder properties
             OptionBuilder.reset();
         }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java
index b209244..e9deeb2 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java
@@ -32,7 +32,7 @@
 public class OptionGroup implements Serializable
 {
     private static final long serialVersionUID = 1L;
-    
+
     /** hold the options */
     private Map optionMap = new HashMap();
 
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java
index a83d125..e051a95 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java
@@ -70,7 +70,8 @@
             {
                 if (!isValidChar(chars[i]))
                 {
-                    throw new IllegalArgumentException("opt contains illegal character value '" + chars[i] + "'");
+                    throw new IllegalArgumentException(
+                        "opt contains illegal character value '" + chars[i] + "'");
                 }
             }
         }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java
index 79508f3..67f667e 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java
@@ -126,7 +126,8 @@
      * @param description Self-documenting description
      * @return the resulting Options instance
      */
-    public Options addOption(String opt, String longOpt, boolean hasArg, String description)
+    public Options addOption(String opt, String longOpt, boolean hasArg,
+        String description)
     {
         addOption(new Option(opt, longOpt, hasArg, description));
 
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java
index 73fd762..bca2633 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java
@@ -68,7 +68,8 @@
      * flattening when a non option has been encountered
      * @return a String array of the flattened arguments
      */
-    protected abstract String[] flatten(Options opts, String[] arguments, boolean stopAtNonOption);
+    protected abstract String[] flatten(Options opts, String[] arguments,
+        boolean stopAtNonOption);
 
     /**
      * Parses the specified <code>arguments</code> based
@@ -97,7 +98,8 @@
      *
      * @since 1.1
      */
-    public CommandLine parse(Options options, String[] arguments, Properties properties) throws ParseException
+    public CommandLine parse(Options options, String[] arguments, Properties properties)
+        throws ParseException
     {
         return parse(options, arguments, properties, false);
     }
@@ -114,7 +116,8 @@
      * @return the <code>CommandLine</code>
      * @throws ParseException if an error occurs when parsing the arguments.
      */
-    public CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException
+    public CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption)
+        throws ParseException
     {
         return parse(options, arguments, null, stopAtNonOption);
     }
@@ -136,8 +139,8 @@
      *
      * @since 1.1
      */
-    public CommandLine parse(Options options, String[] arguments, Properties properties, boolean stopAtNonOption)
-            throws ParseException
+    public CommandLine parse(Options options, String[] arguments, Properties properties,
+        boolean stopAtNonOption) throws ParseException
     {
         // clear out the data in options in case it's been used before (CLI-71)
         for (Iterator it = options.helpOptions().iterator(); it.hasNext();)
@@ -271,8 +274,7 @@
                     }
                 }
                 else if (!("yes".equalsIgnoreCase(value)
-                        || "true".equalsIgnoreCase(value)
-                        || "1".equalsIgnoreCase(value)))
+                    || "true".equalsIgnoreCase(value) || "1".equalsIgnoreCase(value)))
                 {
                     // if the value is not yes, true or 1 then don't add the
                     // option to the CommandLine
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java
index 34a0662..596e6b3 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java
@@ -127,16 +127,8 @@
      */
     public static boolean isValueCode(char ch)
     {
-        return ch == '@'
-                || ch == ':'
-                || ch == '%'
-                || ch == '+'
-                || ch == '#'
-                || ch == '<'
-                || ch == '>'
-                || ch == '*'
-                || ch == '/'
-                || ch == '!';
+        return ch == '@' || ch == ':' || ch == '%' || ch == '+' || ch == '#' || ch == '<'
+            || ch == '>' || ch == '*' || ch == '/' || ch == '!';
     }
 
     /**
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java
index bc0a846..5969db6 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java
@@ -92,7 +92,8 @@
      * when an non option is found.
      * @return The flattened <code>arguments</code> String array.
      */
-    protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+    protected String[] flatten(Options options, String[] arguments,
+        boolean stopAtNonOption)
     {
         init();
         this.options = options;
@@ -119,7 +120,7 @@
                 else
                 {
                     currentOption = options.getOption(opt);
-                    
+
                     tokens.add(opt);
                     if (pos != -1)
                     {
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java
index 8f87762..cffe14b 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java
@@ -43,8 +43,7 @@
      * @return The instance of <code>obj</code> initialised with
      * the value of <code>str</code>.
      */
-    public static Object createValue(String str, Object obj)
-    throws ParseException
+    public static Object createValue(String str, Object obj) throws ParseException
     {
         return createValue(str, (Class) obj);
     }
@@ -58,8 +57,7 @@
      * @return The instance of <code>clazz</code> initialised with
      * the value of <code>str</code>.
      */
-    public static Object createValue(String str, Class clazz)
-    throws ParseException
+    public static Object createValue(String str, Class clazz) throws ParseException
     {
         if (PatternOptionBuilder.STRING_VALUE == clazz)
         {
@@ -110,8 +108,7 @@
       * @return the initialised object, or null if it couldn't create
       * the Object.
       */
-    public static Object createObject(String classname)
-    throws ParseException
+    public static Object createObject(String classname) throws ParseException
     {
         Class cl = null;
 
@@ -132,7 +129,8 @@
         }
         catch (Exception e)
         {
-            throw new ParseException(e.getClass().getName() + "; Unable to create an instance of: " + classname);
+            throw new ParseException(e.getClass().getName()
+                + "; Unable to create an instance of: " + classname);
         }
 
         return instance;
@@ -146,8 +144,7 @@
      * @return the number represented by <code>str</code>, if <code>str</code>
      * is not a number, null is returned.
      */
-    public static Number createNumber(String str)
-    throws ParseException
+    public static Number createNumber(String str) throws ParseException
     {
         try
         {
@@ -172,8 +169,7 @@
      * @param classname the class name
      * @return The class if it is found, otherwise return null
      */
-    public static Class createClass(String classname)
-    throws ParseException
+    public static Class createClass(String classname) throws ParseException
     {
         try
         {
@@ -192,8 +188,7 @@
      * @return The date if <code>str</code> is a valid date string,
      * otherwise return null.
      */
-    public static Date createDate(String str)
-    throws ParseException
+    public static Date createDate(String str) throws ParseException
     {
         throw new UnsupportedOperationException("Not yet implemented");
     }
@@ -205,8 +200,7 @@
      * @return The URL is <code>str</code> is well-formed, otherwise
      * return null.
      */
-    public static URL createURL(String str)
-    throws ParseException
+    public static URL createURL(String str) throws ParseException
     {
         try
         {
@@ -224,8 +218,7 @@
      * @param str the File location
      * @return The file represented by <code>str</code>.
      */
-    public static File createFile(String str)
-    throws ParseException
+    public static File createFile(String str) throws ParseException
     {
         return new File(str);
     }
@@ -236,8 +229,7 @@
      * @param str the paths to the files
      * @return The File[] represented by <code>str</code>.
      */
-    public static File[] createFiles(String str)
-    throws ParseException
+    public static File[] createFiles(String str) throws ParseException
     {
         // to implement/port:
         //        return FileW.findFiles(str);
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java
index 3beef14..40dd629 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime.io;
 
-
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -34,7 +33,6 @@
 import static org.apache.felix.sigil.common.runtime.io.Constants.OK;
 import static org.apache.felix.sigil.common.runtime.io.Constants.ERROR;
 
-
 /**
  * @author dave
  *
@@ -46,123 +44,118 @@
     private final DataInputStream in;
     private final DataOutputStream out;
 
-
-    public Action( DataInputStream in, DataOutputStream out ) throws IOException
+    public Action(DataInputStream in, DataOutputStream out) throws IOException
     {
         this.in = in;
         this.out = out;
     }
 
-
     public O client() throws IOException, BundleException
     {
-        return client( null );
+        return client(null);
     }
 
+    public abstract O client(I input) throws IOException, BundleException;
 
-    public abstract O client( I input ) throws IOException, BundleException;
-
-
-    public abstract void server( Framework fw ) throws IOException;
-
+    public abstract void server(Framework fw) throws IOException;
 
     protected boolean checkOk() throws IOException
     {
         int ch = readInt();
-        switch ( ch )
+        switch (ch)
         {
             case OK:
                 return true;
             case ERROR:
                 return false;
             default:
-                throw new IOException( "Unexpected return code " + ch );
+                throw new IOException("Unexpected return code " + ch);
         }
     }
 
-
     protected void writeOk() throws IOException
     {
-        writeInt( OK );
+        writeInt(OK);
     }
 
-
     protected void writeError() throws IOException
     {
-        writeInt( ERROR );
+        writeInt(ERROR);
     }
 
-    protected void writeThrowable(Throwable t) throws IOException {
+    protected void writeThrowable(Throwable t) throws IOException
+    {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        t.printStackTrace(new PrintStream( bos ));
-        writeString( bos.toString() );
+        t.printStackTrace(new PrintStream(bos));
+        writeString(bos.toString());
     }
 
     protected String readString() throws IOException
     {
         int l = in.readInt();
-        if ( l == -1 ) {
+        if (l == -1)
+        {
             return null;
         }
-        else {
+        else
+        {
             byte[] buf = new byte[l];
-            in.readFully( buf );
+            in.readFully(buf);
             return new String(buf, ASCII);
         }
     }
 
-
-    protected void writeString( String str ) throws IOException
+    protected void writeString(String str) throws IOException
     {
-        if ( str == null ) {
+        if (str == null)
+        {
             out.writeInt(-1);
         }
-        else {
-            byte[] buf = str.getBytes( ASCII );
-            out.writeInt( buf.length );
-            out.write( buf );
+        else
+        {
+            byte[] buf = str.getBytes(ASCII);
+            out.writeInt(buf.length);
+            out.write(buf);
         }
     }
 
-
-    protected void writeInt( int i ) throws IOException
+    protected void writeInt(int i) throws IOException
     {
-        out.writeInt( i );
+        out.writeInt(i);
     }
 
-
     protected int readInt() throws IOException
     {
         return in.readInt();
     }
 
-
-    protected void writeLong( long l ) throws IOException
-    {        
-        out.writeLong( l );
+    protected void writeLong(long l) throws IOException
+    {
+        out.writeLong(l);
     }
 
-
     protected long readLong() throws IOException
     {
         return in.readLong();
     }
 
-    protected void writeBoolean( boolean b ) throws IOException
+    protected void writeBoolean(boolean b) throws IOException
     {
-        out.writeBoolean( b );
+        out.writeBoolean(b);
     }
-    
-    protected boolean readBoolean() throws IOException {
+
+    protected boolean readBoolean() throws IOException
+    {
         return in.readBoolean();
     }
-    
+
     protected void flush() throws IOException
     {
         out.flush();
     }
-    
-    protected void log(String msg) {
-        Main.log( msg );
+
+    protected void log(String msg)
+    {
+        Main.log(msg);
     }
 }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Constants.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Constants.java
index d3221a8..2f56779 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Constants.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Constants.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime.io;
 
-
 public interface Constants
 {
     public static final int OK = 0;
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/InstallAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/InstallAction.java
index 3a822ec..8fe3210 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/InstallAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/InstallAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime.io;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -30,7 +29,6 @@
 
 import static org.apache.felix.sigil.common.runtime.io.Constants.INSTALL;
 
-
 /**
  * @author dave
  *
@@ -38,46 +36,44 @@
 public class InstallAction extends Action<String, Long>
 {
 
-    public InstallAction( DataInputStream in, DataOutputStream out ) throws IOException
+    public InstallAction(DataInputStream in, DataOutputStream out) throws IOException
     {
-        super( in, out );
+        super(in, out);
     }
 
-
     @Override
-    public Long client( String url ) throws IOException, BundleException
+    public Long client(String url) throws IOException, BundleException
     {
-        writeInt( INSTALL );
-        writeString( url );
+        writeInt(INSTALL);
+        writeString(url);
         flush();
-        if ( checkOk() )
+        if (checkOk())
         {
             return readLong();
         }
         else
         {
             String msg = readString();
-            throw new BundleException( msg );
+            throw new BundleException(msg);
         }
     }
 
-
     @Override
-    public void server( Framework fw ) throws IOException
+    public void server(Framework fw) throws IOException
     {
         String url = readString();
         try
         {
-            Bundle val = fw.getBundleContext().installBundle( url );
-            log( "Installed " + url );
+            Bundle val = fw.getBundleContext().installBundle(url);
+            log("Installed " + url);
             writeOk();
-            writeLong( val.getBundleId() );
+            writeLong(val.getBundleId());
         }
-        catch ( BundleException e )
+        catch (BundleException e)
         {
             e.printStackTrace();
             writeError();
-            writeThrowable( e );
+            writeThrowable(e);
         }
         flush();
     }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/RefreshAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/RefreshAction.java
index 9f0064d..c2ec3ec 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/RefreshAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/RefreshAction.java
@@ -40,30 +40,35 @@
     @Override
     public Void client(Void input) throws IOException, BundleException
     {
-        writeInt( REFRESH );
+        writeInt(REFRESH);
         flush();
-        if ( checkOk() )
+        if (checkOk())
         {
             return null;
         }
         else
         {
             String msg = readString();
-            throw new BundleException( msg );
+            throw new BundleException(msg);
         }
     }
 
     @Override
     public void server(Framework fw) throws IOException
     {
-        ServiceReference ref = fw.getBundleContext().getServiceReference(PackageAdmin.class.getName());
-        if ( ref != null ) {
+        ServiceReference ref = fw.getBundleContext().getServiceReference(
+            PackageAdmin.class.getName());
+        if (ref != null)
+        {
             PackageAdmin pa = (PackageAdmin) fw.getBundleContext().getService(ref);
-            if ( pa != null ) {
-                try {
+            if (pa != null)
+            {
+                try
+                {
                     pa.refreshPackages(null);
                 }
-                finally {
+                finally
+                {
                     fw.getBundleContext().ungetService(ref);
                 }
             }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StartAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StartAction.java
index 41958cc..3eb8d0a 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StartAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StartAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime.io;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -30,7 +29,6 @@
 
 import static org.apache.felix.sigil.common.runtime.io.Constants.START;
 
-
 /**
  * @author dave
  *
@@ -38,36 +36,34 @@
 public class StartAction extends Action<Long, Void>
 {
 
-    public StartAction( DataInputStream in, DataOutputStream out ) throws IOException
+    public StartAction(DataInputStream in, DataOutputStream out) throws IOException
     {
-        super( in, out );
+        super(in, out);
     }
 
-
     @Override
-    public Void client( Long bundle ) throws IOException, BundleException
+    public Void client(Long bundle) throws IOException, BundleException
     {
-        writeInt( START );
-        writeLong( bundle );
+        writeInt(START);
+        writeLong(bundle);
         flush();
-        if ( !checkOk() )
+        if (!checkOk())
         {
             String msg = readString();
-            throw new BundleException( msg );
+            throw new BundleException(msg);
         }
         return null;
     }
 
-
     @Override
-    public void server( Framework fw ) throws IOException
+    public void server(Framework fw) throws IOException
     {
         long id = readLong();
-        Bundle b = fw.getBundleContext().getBundle( id );
-        if ( b == null )
+        Bundle b = fw.getBundleContext().getBundle(id);
+        if (b == null)
         {
             writeError();
-            writeString( "Unknown bundle " + id );
+            writeString("Unknown bundle " + id);
         }
         else
         {
@@ -75,9 +71,9 @@
             {
                 b.start();
                 writeOk();
-                log( "Started " + b.getSymbolicName() );
+                log("Started " + b.getSymbolicName());
             }
-            catch ( BundleException e )
+            catch (BundleException e)
             {
                 writeError();
                 writeThrowable(e);
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StatusAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StatusAction.java
index 687ee4f..8fdebd7 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StatusAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StatusAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime.io;
 
-
 import java.io.DataInputStream;
 
 import java.io.DataOutputStream;
@@ -34,7 +33,6 @@
 import static org.osgi.framework.Constants.BUNDLE_VERSION;
 import static org.osgi.framework.Constants.BUNDLE_NAME;
 
-
 /**
  * @author dave
  *
@@ -42,21 +40,21 @@
 public class StatusAction extends Action<Void, BundleStatus[]>
 {
 
-    public StatusAction( DataInputStream in, DataOutputStream out ) throws IOException
+    public StatusAction(DataInputStream in, DataOutputStream out) throws IOException
     {
-        super( in, out );
+        super(in, out);
     }
 
-
     @Override
-    public BundleStatus[] client( Void in ) throws IOException
+    public BundleStatus[] client(Void in) throws IOException
     {
         writeInt(STATUS);
         flush();
         int num = readInt();
         ArrayList<BundleStatus> ret = new ArrayList<BundleStatus>(num);
-        
-        for (int i = 0; i < num; i++) {
+
+        for (int i = 0; i < num; i++)
+        {
             BundleStatus s = new BundleStatus();
             s.setId(readLong());
             s.setBundleSymbolicName(readString());
@@ -65,29 +63,29 @@
             s.setStatus(readInt());
             ret.add(s);
         }
-        
+
         return ret.toArray(new BundleStatus[num]);
     }
 
-
     @Override
-    public void server( Framework fw ) throws IOException
+    public void server(Framework fw) throws IOException
     {
-        log( "Read status" );
+        log("Read status");
         Bundle[] bundles = fw.getBundleContext().getBundles();
-        writeInt( bundles.length );
-        for ( Bundle b : bundles ) {
+        writeInt(bundles.length);
+        for (Bundle b : bundles)
+        {
             writeLong(b.getBundleId());
             String bsn = b.getSymbolicName();
-            if ( bsn == null )
+            if (bsn == null)
                 bsn = (String) b.getHeaders().get(BUNDLE_NAME);
-            
+
             writeString(bsn);
-            writeString((String) b.getHeaders().get( BUNDLE_VERSION ));
+            writeString((String) b.getHeaders().get(BUNDLE_VERSION));
             writeString(b.getLocation());
             writeInt(b.getState());
             flush();
         }
-        flush();        
+        flush();
     }
 }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StopAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StopAction.java
index a44818b..5af9355 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StopAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StopAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime.io;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -30,7 +29,6 @@
 
 import static org.apache.felix.sigil.common.runtime.io.Constants.STOP;
 
-
 /**
  * @author dave
  *
@@ -38,36 +36,34 @@
 public class StopAction extends Action<Long, Void>
 {
 
-    public StopAction( DataInputStream in, DataOutputStream out ) throws IOException
+    public StopAction(DataInputStream in, DataOutputStream out) throws IOException
     {
-        super( in, out );
+        super(in, out);
         // TODO Auto-generated constructor stub
     }
 
-
     @Override
-    public Void client( Long bundle ) throws IOException, BundleException
+    public Void client(Long bundle) throws IOException, BundleException
     {
-        writeInt( STOP );
-        writeLong( bundle );
-        if ( !checkOk() )
+        writeInt(STOP);
+        writeLong(bundle);
+        if (!checkOk())
         {
             String msg = readString();
-            throw new BundleException( msg );
+            throw new BundleException(msg);
         }
         return null;
     }
 
-
     @Override
-    public void server( Framework fw ) throws IOException
+    public void server(Framework fw) throws IOException
     {
         long id = readLong();
-        Bundle b = fw.getBundleContext().getBundle( id );
-        if ( b == null )
+        Bundle b = fw.getBundleContext().getBundle(id);
+        if (b == null)
         {
             writeError();
-            writeString( "Unknown bundle " + id );
+            writeString("Unknown bundle " + id);
         }
         else
         {
@@ -76,10 +72,10 @@
                 b.stop();
                 writeOk();
             }
-            catch ( BundleException e )
+            catch (BundleException e)
             {
                 writeError();
-                writeThrowable( e );
+                writeThrowable(e);
             }
         }
     }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UninstallAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UninstallAction.java
index eddf847..7212b26 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UninstallAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UninstallAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime.io;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -30,7 +29,6 @@
 
 import static org.apache.felix.sigil.common.runtime.io.Constants.UNINSTALL;
 
-
 /**
  * @author dave
  *
@@ -38,35 +36,33 @@
 public class UninstallAction extends Action<Long, Void>
 {
 
-    public UninstallAction( DataInputStream in, DataOutputStream out ) throws IOException
+    public UninstallAction(DataInputStream in, DataOutputStream out) throws IOException
     {
-        super( in, out );
+        super(in, out);
     }
 
-
     @Override
-    public Void client( Long bundle ) throws IOException, BundleException
+    public Void client(Long bundle) throws IOException, BundleException
     {
-        writeInt( UNINSTALL );
-        writeLong( bundle );
-        if ( !checkOk() )
+        writeInt(UNINSTALL);
+        writeLong(bundle);
+        if (!checkOk())
         {
             String msg = readString();
-            throw new BundleException( msg );
+            throw new BundleException(msg);
         }
         return null;
     }
 
-
     @Override
-    public void server( Framework fw ) throws IOException
+    public void server(Framework fw) throws IOException
     {
         long id = readLong();
-        Bundle b = fw.getBundleContext().getBundle( id );
-        if ( b == null )
+        Bundle b = fw.getBundleContext().getBundle(id);
+        if (b == null)
         {
             writeError();
-            writeString( "Unknown bundle " + id );
+            writeString("Unknown bundle " + id);
         }
         else
         {
@@ -75,10 +71,10 @@
                 b.uninstall();
                 writeOk();
             }
-            catch ( BundleException e )
+            catch (BundleException e)
             {
                 writeError();
-                writeThrowable( e );
+                writeThrowable(e);
             }
         }
     }
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UpdateAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UpdateAction.java
index 905e0b7..628fdd9 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UpdateAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UpdateAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.common.runtime.io;
 
-
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -32,7 +31,6 @@
 
 import static org.apache.felix.sigil.common.runtime.io.Constants.UPDATE;
 
-
 /**
  * @author dave
  *
@@ -44,79 +42,79 @@
         final long bundleID;
         final String location;
 
-
-        public Update( long bundleID, String location )
+        public Update(long bundleID, String location)
         {
             this.bundleID = bundleID;
             this.location = location;
         }
     }
 
-
-    public UpdateAction( DataInputStream in, DataOutputStream out ) throws IOException
+    public UpdateAction(DataInputStream in, DataOutputStream out) throws IOException
     {
-        super( in, out );
+        super(in, out);
         // TODO Auto-generated constructor stub
     }
 
-
     @Override
-    public Void client( Update update ) throws IOException, BundleException
+    public Void client(Update update) throws IOException, BundleException
     {
-        writeInt( UPDATE );
-        writeLong( update.bundleID );
-        if ( update.location == null )
+        writeInt(UPDATE);
+        writeLong(update.bundleID);
+        if (update.location == null)
         {
-            writeBoolean( false );
+            writeBoolean(false);
         }
         else
         {
-            writeBoolean( true );
-            writeString( update.location );
+            writeBoolean(true);
+            writeString(update.location);
         }
         flush();
 
-        if ( !checkOk() )
+        if (!checkOk())
         {
             String msg = readString();
-            throw new BundleException( msg );
+            throw new BundleException(msg);
         }
 
         return null;
     }
 
-
     @Override
-    public void server( Framework fw ) throws IOException
+    public void server(Framework fw) throws IOException
     {
         long id = readLong();
-        Bundle b = fw.getBundleContext().getBundle( id );
-        if ( b == null )
+        Bundle b = fw.getBundleContext().getBundle(id);
+        if (b == null)
         {
             writeError();
-            writeString( "Unknown bundle " + id );
+            writeString("Unknown bundle " + id);
         }
         else
         {
             try
             {
                 boolean remote = readBoolean();
-                if ( remote )
+                if (remote)
                 {
                     String loc = readString();
-                    try {
-                        InputStream in = open( loc );
-                        try {
+                    try
+                    {
+                        InputStream in = open(loc);
+                        try
+                        {
                             b.update(in);
                             writeOk();
                         }
-                        finally {
+                        finally
+                        {
                             in.close();
                         }
                     }
-                    catch (IOException e) {
+                    catch (IOException e)
+                    {
                         writeError();
-                        writeThrowable( e );
+                        writeThrowable(e);
                     }
                 }
                 else
@@ -125,20 +123,19 @@
                     writeOk();
                 }
             }
-            catch ( BundleException e )
+            catch (BundleException e)
             {
                 writeError();
-                writeString( e.getMessage() );
+                writeString(e.getMessage());
             }
         }
 
         flush();
     }
 
-
-    private InputStream open( String loc ) throws IOException
+    private InputStream open(String loc) throws IOException
     {
-        URL url = new URL( loc );
+        URL url = new URL(loc);
         return url.openStream();
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java
index e3a524b..9cea7fd 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java
@@ -39,18 +39,18 @@
         return path == null ? null : new Path(path);
     }
 
-
     /**
      * @param absolutePath
      * @return
      */
     public static IPath newPathIfExists(File file)
     {
-        if (file == null) return null;
-        if (file.exists()) return new Path(file.getAbsolutePath());
+        if (file == null)
+            return null;
+        if (file.exists())
+            return new Path(file.getAbsolutePath());
         // fine
         return null;
     }
 
-
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
index defb0fa..4f76a03 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -81,7 +80,6 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.util.tracker.ServiceTracker;
 
-
 /**
  * The activator class controls the plug-in life cycle
  */
@@ -92,19 +90,25 @@
     // The plug-in ID
     public static final String PLUGIN_ID = BASE + ".eclipse.core";
     public static final String NATURE_ID = BASE + ".sigilnature";
-    public static final String PREFERENCES_ID = BASE + ".ui.preferences.SigilPreferencePage";
-    public static final String OSGI_INSTALLS_PREFERENCES_ID = BASE + ".ui.preferences.osgiInstalls";
-    public static final String EXCLUDED_RESOURCES_PREFERENCES_ID = BASE + ".ui.preferences.excludedResources";
-    public static final String REPOSITORIES_PREFERENCES_ID = BASE + ".ui.preferences.repositoriesPreferencePage";
+    public static final String PREFERENCES_ID = BASE
+        + ".ui.preferences.SigilPreferencePage";
+    public static final String OSGI_INSTALLS_PREFERENCES_ID = BASE
+        + ".ui.preferences.osgiInstalls";
+    public static final String EXCLUDED_RESOURCES_PREFERENCES_ID = BASE
+        + ".ui.preferences.excludedResources";
+    public static final String REPOSITORIES_PREFERENCES_ID = BASE
+        + ".ui.preferences.repositoriesPreferencePage";
     public static final String SIGIL_PROJECT_FILE = IBldProject.PROJECT_FILE;
     public static final String BUILDER_ID = PLUGIN_ID + ".sigilBuilder";
     public static final String CLASSPATH_CONTAINER_PATH = BASE + ".classpathContainer";
 
     public static final String OSGI_INSTALLS = BASE + ".osgi.installs";
-    public static final String OSGI_DEFAULT_INSTALL_ID = BASE + ".osgi.default.install.id";
+    public static final String OSGI_DEFAULT_INSTALL_ID = BASE
+        + ".osgi.default.install.id";
     public static final String OSGI_INSTALL_PREFIX = BASE + ".osgi.install.";
     public static final String OSGI_SOURCE_LOCATION = BASE + ".osgi.source.location";
-    public static final String OSGI_INSTALL_CHECK_PREFERENCE = BASE + ".osgi.install.check";
+    public static final String OSGI_INSTALL_CHECK_PREFERENCE = BASE
+        + ".osgi.install.check";
     public static final String LIBRARY_KEYS_PREF = BASE + ".library.keys";
     public static final String PREFERENCES_REBUILD_PROJECTS = BASE + ".rebuild.projects";
     public static final String QUALIFY_VERSIONS = BASE + ".qualify.versions";
@@ -113,20 +117,29 @@
     public static final String DEFAULT_VERSION_UPPER_BOUND = BASE + ".versionUpperBound";
 
     public static final String DEFAULT_EXCLUDED_RESOURCES = BASE + ".excludedResources";
-    public static final String INCLUDE_OPTIONAL_DEPENDENCIES = BASE + ".includeOptionalDependencies";
+    public static final String INCLUDE_OPTIONAL_DEPENDENCIES = BASE
+        + ".includeOptionalDependencies";
 
-    public static final String INSTALL_BUILDER_EXTENSION_POINT_ID = BASE + ".installbuilder";
-    public static final String REPOSITORY_PROVIDER_EXTENSION_POINT_ID = BASE + ".repositoryprovider";
+    public static final String INSTALL_BUILDER_EXTENSION_POINT_ID = BASE
+        + ".installbuilder";
+    public static final String REPOSITORY_PROVIDER_EXTENSION_POINT_ID = BASE
+        + ".repositoryprovider";
 
-    public static final String MARKER_UNRESOLVED_DEPENDENCY = BASE + ".unresolvedDependencyMarker";
-    public static final String MARKER_UNRESOLVED_IMPORT_PACKAGE = BASE + ".unresolvedDependencyMarker.importPackage";
-    public static final String MARKER_UNRESOLVED_REQUIRE_BUNDLE = BASE + ".unresolvedDependencyMarker.requireBundle";
+    public static final String MARKER_UNRESOLVED_DEPENDENCY = BASE
+        + ".unresolvedDependencyMarker";
+    public static final String MARKER_UNRESOLVED_IMPORT_PACKAGE = BASE
+        + ".unresolvedDependencyMarker.importPackage";
+    public static final String MARKER_UNRESOLVED_REQUIRE_BUNDLE = BASE
+        + ".unresolvedDependencyMarker.requireBundle";
     public static final String REPOSITORY_SET = PLUGIN_ID + ".repository.set";
-    
+
     public static final String PREFERENCES_NOASK_OSGI_INSTALL = BASE + ".noAskOSGIHome";
-    public static final String PREFERENCES_ADD_IMPORT_FOR_EXPORT = BASE + ".addImportForExport";
-    public static final String PREFERENCES_INCLUDE_OPTIONAL = PLUGIN_ID + ".include.optional";
-    public static final String PREFERENCES_REMOVE_IMPORT_FOR_EXPORT = BASE + ".removeImportForExport";
+    public static final String PREFERENCES_ADD_IMPORT_FOR_EXPORT = BASE
+        + ".addImportForExport";
+    public static final String PREFERENCES_INCLUDE_OPTIONAL = PLUGIN_ID
+        + ".include.optional";
+    public static final String PREFERENCES_REMOVE_IMPORT_FOR_EXPORT = BASE
+        + ".removeImportForExport";
 
     private static final Object NULL = new Object();
 
@@ -154,72 +167,64 @@
         return plugin;
     }
 
-
-    public static CoreException newCoreException( String msg, Throwable t )
+    public static CoreException newCoreException(String msg, Throwable t)
     {
-        return new CoreException( makeStatus( msg, t, IStatus.ERROR ) );
+        return new CoreException(makeStatus(msg, t, IStatus.ERROR));
     }
 
-
-    public static void log( String msg )
+    public static void log(String msg)
     {
-        DebugPlugin.log( makeStatus( msg, null, IStatus.INFO ) );
+        DebugPlugin.log(makeStatus(msg, null, IStatus.INFO));
     }
 
-
-    public static void error( String msg )
+    public static void error(String msg)
     {
-        DebugPlugin.log( makeStatus( msg, null, IStatus.ERROR ) );
+        DebugPlugin.log(makeStatus(msg, null, IStatus.ERROR));
     }
 
-
-    public static void error( String msg, Throwable t )
+    public static void error(String msg, Throwable t)
     {
-        DebugPlugin.log( makeStatus( msg, t, IStatus.ERROR ) );
+        DebugPlugin.log(makeStatus(msg, t, IStatus.ERROR));
     }
 
-
-    public static void warn( String msg )
+    public static void warn(String msg)
     {
-        DebugPlugin.log( makeStatus( msg, null, IStatus.WARNING ) );
+        DebugPlugin.log(makeStatus(msg, null, IStatus.WARNING));
     }
 
-
-    public static void warn( String msg, Throwable t )
+    public static void warn(String msg, Throwable t)
     {
-        DebugPlugin.log( makeStatus( msg, t, IStatus.WARNING ) );
+        DebugPlugin.log(makeStatus(msg, t, IStatus.WARNING));
     }
 
-
-    private static IStatus makeStatus( String msg, Throwable t, int status )
+    private static IStatus makeStatus(String msg, Throwable t, int status)
     {
-        if ( t instanceof CoreException )
+        if (t instanceof CoreException)
         {
-            CoreException c = ( CoreException ) t;
+            CoreException c = (CoreException) t;
             return c.getStatus();
         }
         else
         {
-            return new Status( status, SigilCore.PLUGIN_ID, status, msg, t );
+            return new Status(status, SigilCore.PLUGIN_ID, status, msg, t);
         }
     }
 
-
-    public static boolean isSigilProject( IProject resource )
+    public static boolean isSigilProject(IProject resource)
     {
-        if ( resource == null )
+        if (resource == null)
             return false;
 
-        if ( resource.isAccessible() && resource instanceof IProject )
+        if (resource.isAccessible() && resource instanceof IProject)
         {
-            IProject project = ( IProject ) resource;
+            IProject project = (IProject) resource;
             try
             {
-                return project.hasNature( NATURE_ID );
+                return project.hasNature(NATURE_ID);
             }
-            catch ( CoreException e )
+            catch (CoreException e)
             {
-                error( e.getMessage(), e );
+                error(e.getMessage(), e);
                 return false;
             }
         }
@@ -229,26 +234,22 @@
         }
     }
 
-
-    public static boolean hasProjectNature( IProject project ) throws CoreException
+    public static boolean hasProjectNature(IProject project) throws CoreException
     {
-        return project.getNature( NATURE_ID ) != null;
+        return project.getNature(NATURE_ID) != null;
     }
 
-
     public static ResourceBundle getResourceBundle()
     {
-        return ResourceBundle.getBundle( "resources." + SigilCore.class.getName(), Locale.getDefault(), SigilCore.class
-            .getClassLoader() );
+        return ResourceBundle.getBundle("resources." + SigilCore.class.getName(),
+            Locale.getDefault(), SigilCore.class.getClassLoader());
     }
 
-
-    public static ISigilProjectModel create( IProject project ) throws CoreException
+    public static ISigilProjectModel create(IProject project) throws CoreException
     {
         return projectManager.getSigilProject(project);
     }
 
-
     /**
      * The constructor
      */
@@ -257,12 +258,10 @@
         plugin = this;
     }
 
-
     public void earlyStartup()
     {
     }
 
-
     /*
      * (non-Javadoc)
      * 
@@ -270,9 +269,9 @@
      * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
      * )
      */
-    public void start( final BundleContext context ) throws Exception
+    public void start(final BundleContext context) throws Exception
     {
-        super.start( context );
+        super.start(context);
 
         modelRoot = new SigilModelRoot();
 
@@ -283,14 +282,13 @@
         repositoryMap = new RepositoryMap();
         globalRepositoryManager = new GlobalRepositoryManager(repositoryMap);
         globalRepositoryManager.initialise();
-        
+
         projectManager = new SigilProjectManager();
 
-        registerModelElements( context );
+        registerModelElements(context);
         registerResourceListeners();
     }
 
-
     /*
      * (non-Javadoc)
      * 
@@ -298,27 +296,27 @@
      * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
      * )
      */
-    public void stop( BundleContext context ) throws Exception
+    public void stop(BundleContext context) throws Exception
     {
-        if ( descriptorTracker != null )
+        if (descriptorTracker != null)
         {
             descriptorTracker.close();
             descriptorTracker = null;
         }
 
-        if ( registryTracker != null )
+        if (registryTracker != null)
         {
             registryTracker.close();
             registryTracker = null;
         }
 
-        if ( serializerTracker != null )
+        if (serializerTracker != null)
         {
             serializerTracker.close();
             serializerTracker = null;
         }
 
-        for ( SigilRepositoryManager m : repositoryManagers.values() )
+        for (SigilRepositoryManager m : repositoryManagers.values())
         {
             m.destroy();
         }
@@ -330,24 +328,23 @@
 
         plugin = null;
 
-        super.stop( context );
+        super.stop(context);
     }
 
-
-    public static boolean isBundledPath( String bp ) throws CoreException
+    public static boolean isBundledPath(String bp) throws CoreException
     {
-        boolean bundle = JavaHelper.isCachedBundle( bp );
+        boolean bundle = JavaHelper.isCachedBundle(bp);
 
-        if ( !bundle )
+        if (!bundle)
         {
-            bundle = isProjectPath( bp );
+            bundle = isProjectPath(bp);
 
-            if ( !bundle )
+            if (!bundle)
             {
-                for ( IBundleRepository r : getGlobalRepositoryManager().getRepositories() )
+                for (IBundleRepository r : getGlobalRepositoryManager().getRepositories())
                 {
-                    bundle = isBundlePath( bp, r );
-                    if ( bundle )
+                    bundle = isBundlePath(bp, r);
+                    if (bundle)
                         break;
                 }
             }
@@ -356,19 +353,18 @@
         return bundle;
     }
 
-
-    private static boolean isBundlePath( final String bp, IBundleRepository r )
+    private static boolean isBundlePath(final String bp, IBundleRepository r)
     {
         final AtomicBoolean flag = new AtomicBoolean();
 
         IRepositoryVisitor visitor = new IRepositoryVisitor()
         {
-            public boolean visit( ISigilBundle b )
+            public boolean visit(ISigilBundle b)
             {
                 File path = b.getLocation();
-                if ( path != null && path.getAbsolutePath().equals( bp ) )
+                if (path != null && path.getAbsolutePath().equals(bp))
                 {
-                    flag.set( true );
+                    flag.set(true);
                     return false;
                 }
                 else
@@ -379,19 +375,18 @@
 
         };
 
-        r.accept( visitor, ResolutionConfig.INDEXED_ONLY | ResolutionConfig.LOCAL_ONLY );
+        r.accept(visitor, ResolutionConfig.INDEXED_ONLY | ResolutionConfig.LOCAL_ONLY);
 
         return flag.get();
     }
 
-
-    private static boolean isProjectPath( String bp ) throws CoreException
+    private static boolean isProjectPath(String bp) throws CoreException
     {
-        for ( ISigilProjectModel p : SigilCore.getRoot().getProjects() )
+        for (ISigilProjectModel p : SigilCore.getRoot().getProjects())
         {
             IPath path = p.findOutputLocation();
 
-            if ( path.toOSString().equals( bp ) )
+            if (path.toOSString().equals(bp))
             {
                 return true;
             }
@@ -400,205 +395,199 @@
         return false;
     }
 
-
     private void registerResourceListeners()
     {
-        Job job = new Job( "Initialising sigil resource listeners" )
+        Job job = new Job("Initialising sigil resource listeners")
         {
             @Override
-            protected IStatus run( IProgressMonitor monitor )
+            protected IStatus run(IProgressMonitor monitor)
             {
-                ResourcesPlugin.getWorkspace().addResourceChangeListener( new ProjectResourceListener(projectManager),
-                    ProjectResourceListener.EVENT_MASKS );
+                ResourcesPlugin.getWorkspace().addResourceChangeListener(
+                    new ProjectResourceListener(projectManager),
+                    ProjectResourceListener.EVENT_MASKS);
                 return Status.OK_STATUS;
             }
         };
-        job.setSystem( true );
+        job.setSystem(true);
         job.schedule();
     }
 
-
-    private void registerModelElements( BundleContext context )
+    private void registerModelElements(BundleContext context)
     {
         // trick to get eclipse to lazy load BldCore for model elements
         BldCore.getLicenseManager();
-        ModelElementFactory.getInstance().register( ISigilProjectModel.class, SigilProject.class, "project", "sigil", null );
+        ModelElementFactory.getInstance().register(ISigilProjectModel.class,
+            SigilProject.class, "project", "sigil", null);
     }
 
-
     public static IOSGiInstallManager getInstallManager()
     {
         return installs;
     }
 
-
     public static ISigilModelRoot getRoot()
     {
         return modelRoot;
     }
 
-
     public static IRepositoryManager getGlobalRepositoryManager()
     {
         return globalRepositoryManager;
     }
 
-
-    public static IRepositoryManager getRepositoryManager( String set )
+    public static IRepositoryManager getRepositoryManager(String set)
     {
         SigilRepositoryManager manager = null;
 
-        if ( set == null )
+        if (set == null)
         {
-            manager = repositoryManagers.get( NULL );
-            if ( manager == null )
+            manager = repositoryManagers.get(NULL);
+            if (manager == null)
             {
-                manager = new SigilRepositoryManager( null, repositoryMap );
+                manager = new SigilRepositoryManager(null, repositoryMap);
                 manager.initialise();
-                repositoryManagers.put( NULL, manager );
+                repositoryManagers.put(NULL, manager);
             }
         }
         else
         {
-            manager = repositoryManagers.get( set );
+            manager = repositoryManagers.get(set);
 
-            if ( manager == null )
+            if (manager == null)
             {
-                manager = new SigilRepositoryManager( set, repositoryMap );
+                manager = new SigilRepositoryManager(set, repositoryMap);
                 manager.initialise();
-                repositoryManagers.put( set, manager );
+                repositoryManagers.put(set, manager);
             }
         }
 
         return manager;
     }
 
-
-    public static IRepositoryManager getRepositoryManager( ISigilProjectModel model )
+    public static IRepositoryManager getRepositoryManager(ISigilProjectModel model)
     {
-        return getRepositoryManager( loadProjectRepositorySet( model ) );
+        return getRepositoryManager(loadProjectRepositorySet(model));
     }
 
-
-    private static String loadProjectRepositorySet( ISigilProjectModel model )
+    private static String loadProjectRepositorySet(ISigilProjectModel model)
     {
-        if ( model == null )
+        if (model == null)
         {
             return null;
         }
 
-        return model.getPreferences().get( REPOSITORY_SET, null );
+        return model.getPreferences().get(REPOSITORY_SET, null);
     }
 
-
     public static IRepositoryConfiguration getRepositoryConfiguration()
     {
         return repositoryConfig;
     }
 
-
-    public static void rebuildAllBundleDependencies( IProgressMonitor monitor )
+    public static void rebuildAllBundleDependencies(IProgressMonitor monitor)
     {
         Collection<ISigilProjectModel> projects = getRoot().getProjects();
-        if ( !projects.isEmpty() )
+        if (!projects.isEmpty())
         {
-            SubMonitor progress = SubMonitor.convert( monitor, projects.size() * 20 );
-            for ( ISigilProjectModel p : projects )
+            SubMonitor progress = SubMonitor.convert(monitor, projects.size() * 20);
+            for (ISigilProjectModel p : projects)
             {
-                rebuild( p, progress );
+                rebuild(p, progress);
             }
         }
 
         monitor.done();
     }
 
-
-    public static void rebuildBundleDependencies( ISigilProjectModel project, Collection<ICapabilityModelElement> caps, IProgressMonitor monitor )
+    public static void rebuildBundleDependencies(ISigilProjectModel project,
+        Collection<ICapabilityModelElement> caps, IProgressMonitor monitor)
     {
-        Set<ISigilProjectModel> affected = SigilCore.getRoot().resolveDependentProjects( caps, monitor );
+        Set<ISigilProjectModel> affected = SigilCore.getRoot().resolveDependentProjects(
+            caps, monitor);
 
-        if ( project != null ) {
-            affected.remove( project );
+        if (project != null)
+        {
+            affected.remove(project);
         }
 
-        SubMonitor progress = SubMonitor.convert( monitor, affected.size() * 20 );
-        for ( ISigilProjectModel dependent : affected )
+        SubMonitor progress = SubMonitor.convert(monitor, affected.size() * 20);
+        for (ISigilProjectModel dependent : affected)
         {
             //dependent.flushDependencyState();
-            rebuild( dependent, progress );
+            rebuild(dependent, progress);
         }
     }
 
-
-    public static void rebuild( ISigilProjectModel dependent, SubMonitor progress )
+    public static void rebuild(ISigilProjectModel dependent, SubMonitor progress)
     {
         try
         {
-            dependent.resetClasspath( progress.newChild( 10 ) );
-            dependent.getProject().build( IncrementalProjectBuilder.FULL_BUILD, progress.newChild( 10 ) );
+            dependent.resetClasspath(progress.newChild(10));
+            dependent.getProject().build(IncrementalProjectBuilder.FULL_BUILD,
+                progress.newChild(10));
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to rebuild " + dependent, e );
+            SigilCore.error("Failed to rebuild " + dependent, e);
         }
     }
 
-
-    public IPath findDefaultBundleLocation( ISigilProjectModel m ) throws CoreException
+    public IPath findDefaultBundleLocation(ISigilProjectModel m) throws CoreException
     {
         IPath loc = m.getProject().getLocation();
-        loc = loc.append( m.getJavaModel().getOutputLocation().removeFirstSegments( 1 ) );
-        loc = loc.removeLastSegments( 1 ).append( "lib" );
-        return loc.append( m.getSymbolicName() + ".jar" );
+        loc = loc.append(m.getJavaModel().getOutputLocation().removeFirstSegments(1));
+        loc = loc.removeLastSegments(1).append("lib");
+        return loc.append(m.getSymbolicName() + ".jar");
     }
 
-
-    public static void makeSigilProject( IProject project, IProgressMonitor monitor ) throws CoreException
+    public static void makeSigilProject(IProject project, IProgressMonitor monitor)
+        throws CoreException
     {
         IProjectDescription description = project.getDescription();
 
         String[] natures = description.getNatureIds();
         String[] newNatures = new String[natures.length + 1];
-        System.arraycopy( natures, 0, newNatures, 0, natures.length );
+        System.arraycopy(natures, 0, newNatures, 0, natures.length);
         newNatures[natures.length] = SigilCore.NATURE_ID;
-        description.setNatureIds( newNatures );
+        description.setNatureIds(newNatures);
 
         ICommand sigilBuild = description.newCommand();
-        sigilBuild.setBuilderName( SigilCore.BUILDER_ID );
+        sigilBuild.setBuilderName(SigilCore.BUILDER_ID);
 
         ICommand javaBuild = description.newCommand();
-        javaBuild.setBuilderName( JavaCore.BUILDER_ID );
+        javaBuild.setBuilderName(JavaCore.BUILDER_ID);
 
-        description.setBuildSpec( new ICommand[]
-            { javaBuild, sigilBuild } );
+        description.setBuildSpec(new ICommand[] { javaBuild, sigilBuild });
 
-        project.setDescription( description, new SubProgressMonitor( monitor, 2 ) );
+        project.setDescription(description, new SubProgressMonitor(monitor, 2));
 
-        IJavaProject java = JavaCore.create( project );
-        if ( java.exists() )
+        IJavaProject java = JavaCore.create(project);
+        if (java.exists())
         {
             IClasspathEntry[] cp = java.getRawClasspath();
             // check if sigil container is already on classpath - if not add it
-            if ( !isSigilOnClasspath( cp ) )
+            if (!isSigilOnClasspath(cp))
             {
-                ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>( Arrays.asList( cp ) );
-                entries.add( JavaCore.newContainerEntry( new Path( SigilCore.CLASSPATH_CONTAINER_PATH ) ) );
-                java.setRawClasspath( entries.toArray( new IClasspathEntry[entries.size()] ), monitor );
+                ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(
+                    Arrays.asList(cp));
+                entries.add(JavaCore.newContainerEntry(new Path(
+                    SigilCore.CLASSPATH_CONTAINER_PATH)));
+                java.setRawClasspath(
+                    entries.toArray(new IClasspathEntry[entries.size()]), monitor);
             }
         }
     }
 
-
     /**
      * @param cp
      * @return
      */
-    private static boolean isSigilOnClasspath( IClasspathEntry[] cp )
+    private static boolean isSigilOnClasspath(IClasspathEntry[] cp)
     {
-        for ( IClasspathEntry e : cp )
+        for (IClasspathEntry e : cp)
         {
-            if ( e.getEntryKind() == IClasspathEntry.CPE_CONTAINER
-                && e.getPath().segment( 0 ).equals( SigilCore.CLASSPATH_CONTAINER_PATH ) )
+            if (e.getEntryKind() == IClasspathEntry.CPE_CONTAINER
+                && e.getPath().segment(0).equals(SigilCore.CLASSPATH_CONTAINER_PATH))
             {
                 return true;
             }
@@ -606,28 +595,26 @@
         return false;
     }
 
-
-    public static Image loadImage( URL url ) throws IOException
+    public static Image loadImage(URL url) throws IOException
     {
         ImageRegistry registry = getDefault().getImageRegistry();
 
         String key = url.toExternalForm();
-        Image img = registry.get( key );
+        Image img = registry.get(key);
 
-        if ( img == null )
+        if (img == null)
         {
-            img = openImage( url );
-            registry.put( key, img );
+            img = openImage(url);
+            registry.put(key, img);
         }
 
         return img;
     }
 
-
-    private static Image openImage( URL url ) throws IOException
+    private static Image openImage(URL url) throws IOException
     {
         Display display = Display.getCurrent();
-        if ( display == null )
+        if (display == null)
         {
             display = Display.getDefault();
         }
@@ -636,19 +623,19 @@
         try
         {
             in = url.openStream();
-            return new Image( display, in );
+            return new Image(display, in);
         }
         finally
         {
-            if ( in != null )
+            if (in != null)
             {
                 try
                 {
                     in.close();
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
-                    error( "Failed to close stream", e );
+                    error("Failed to close stream", e);
                 }
             }
         }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstall.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstall.java
index 154826a..d31cb1f 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstall.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstall.java
@@ -19,12 +19,10 @@
 
 package org.apache.felix.sigil.eclipse.install;
 
-
 import java.util.Map;
 
 import org.eclipse.core.runtime.IPath;
 
-
 /**
  * Encapsulates all information about a particular OSGi install.
  * 
@@ -40,32 +38,27 @@
      */
     String getId();
 
-
     /**
      * Where this install is located
      * @return
      */
     IPath getInstallLocation();
 
-
     /**
      * @return
      */
     Map<String, String> getProperties();
 
-
     /**
      * @return
      */
     String[] getLaunchArguments();
 
-
     /**
      * @return
      */
     IPath getVarDirectory();
 
-
     /**
      * @return
      */
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallBuilder.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallBuilder.java
index 69cdbdc..2dd5148 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallBuilder.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallBuilder.java
@@ -19,12 +19,10 @@
 
 package org.apache.felix.sigil.eclipse.install;
 
-
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 
-
 public interface IOSGiInstallBuilder
 {
-    IOSGiInstall build( String id, IPath path ) throws CoreException;
+    IOSGiInstall build(String id, IPath path) throws CoreException;
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallManager.java
index 3661463..2c304b4 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallManager.java
@@ -19,20 +19,15 @@
 
 package org.apache.felix.sigil.eclipse.install;
 
-
 public interface IOSGiInstallManager
 {
-    IOSGiInstall findInstall( String id );
-
+    IOSGiInstall findInstall(String id);
 
     String[] getInstallIDs();
 
-
     IOSGiInstall[] getInstalls();
 
-
     IOSGiInstall getDefaultInstall();
 
-
-    IOSGiInstallType findInstallType( String location );
+    IOSGiInstallType findInstallType(String location);
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallType.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallType.java
index 933f54d..be117e6 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallType.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallType.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.install;
 
-
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.swt.graphics.Image;
 
-
 //import org.eclipse.swt.graphics.Image;
 
 public interface IOSGiInstallType
@@ -33,47 +31,39 @@
      */
     String getName();
 
-
     /**
      * 
      * @return
      */
     String getVersion();
 
-
     /**
      * @return
      */
     String getMainClass();
 
-
     /**
      * @return
      */
     String[] getClassPath();
 
-
     /**
      * @return
      */
     IPath getSourceLocation();
 
-
     /**
      * @return
      */
     IPath getJavaDocLocation();
 
-
     /**
      * Return the paths of any bundles that are started by default in this OSGi instance.
      * @return
      */
     IPath[] getDefaultBundleLocations();
 
-
     String getId();
 
-
     Image getIcon();
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstall.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstall.java
index 4cf4604..7b98c2c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstall.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstall.java
@@ -19,13 +19,11 @@
 
 package org.apache.felix.sigil.eclipse.install;
 
-
 import java.util.Arrays;
 import java.util.Map;
 
 import org.eclipse.core.runtime.IPath;
 
-
 public class OSGiInstall implements IOSGiInstall
 {
 
@@ -36,81 +34,69 @@
     private IPath varDirectory;
     private IOSGiInstallType type;
 
-
     public IPath getVarDirectory()
     {
         return varDirectory;
     }
 
-
-    public void setVarDirectory( IPath varDirectory )
+    public void setVarDirectory(IPath varDirectory)
     {
         this.varDirectory = varDirectory;
     }
 
-
-    public OSGiInstall( String id )
+    public OSGiInstall(String id)
     {
         this.id = id;
     }
 
-
     public String getId()
     {
         return id;
     }
 
-
     public IPath getInstallLocation()
     {
         return installLocation;
     }
 
-
-    public void setInstallLocation( IPath installLocation )
+    public void setInstallLocation(IPath installLocation)
     {
         this.installLocation = installLocation;
     }
 
-
     public String[] getLaunchArguments()
     {
         return launchArgs;
     }
 
-
-    public void setLaunchArguments( String[] launchArgs )
+    public void setLaunchArguments(String[] launchArgs)
     {
         this.launchArgs = launchArgs;
     }
 
-
     public Map<String, String> getProperties()
     {
         return properties;
     }
 
-
-    public void setProperties( Map<String, String> properties )
+    public void setProperties(Map<String, String> properties)
     {
         this.properties = properties;
     }
 
-
     public String toString()
     {
-        return "OSGiInstall[\n" + "id=" + id + "\n" + "type=" + type + "\n" + "installLocation=" + installLocation
-            + "\n" + "launchArgs=" + Arrays.asList( launchArgs ) + "\n" + "properties=" + properties + "\n" + "]";
+        return "OSGiInstall[\n" + "id=" + id + "\n" + "type=" + type + "\n"
+            + "installLocation=" + installLocation + "\n" + "launchArgs="
+            + Arrays.asList(launchArgs) + "\n" + "properties=" + properties + "\n" + "]";
     }
 
-
     public IOSGiInstallType getType()
     {
         return type;
     }
 
-
-    public void setType( IOSGiInstallType type )
+    public void setType(IOSGiInstallType type)
     {
         this.type = type;
     }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstallType.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstallType.java
index 18472a7..63c4ffe 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstallType.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstallType.java
@@ -19,13 +19,11 @@
 
 package org.apache.felix.sigil.eclipse.install;
 
-
 import java.util.Arrays;
 
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.swt.graphics.Image;
 
-
 public class OSGiInstallType implements IOSGiInstallType
 {
 
@@ -39,120 +37,102 @@
     private IPath[] defaultBundleLocations;
     private Image icon;
 
-
     public Image getIcon()
     {
         return icon;
     }
 
-
-    public void setIcon( Image icon )
+    public void setIcon(Image icon)
     {
         this.icon = icon;
     }
 
-
     public String getId()
     {
         return id;
     }
 
-
     public String[] getClassPath()
     {
         return classPath;
     }
 
-
     public IPath[] getDefaultBundleLocations()
     {
         return defaultBundleLocations;
     }
 
-
     public IPath getJavaDocLocation()
     {
         return javaDocLocation;
     }
 
-
     public String getMainClass()
     {
         return mainClass;
     }
 
-
     public String getName()
     {
         return name;
     }
 
-
     public IPath getSourceLocation()
     {
         return sourceLocation;
     }
 
-
     public String getVersion()
     {
         return version;
     }
 
-
-    public void setId( String id )
+    public void setId(String id)
     {
         this.id = id;
     }
 
-
-    public void setName( String name )
+    public void setName(String name)
     {
         this.name = name;
     }
 
-
-    public void setVersion( String version )
+    public void setVersion(String version)
     {
         this.version = version;
     }
 
-
-    public void setMainClass( String mainClass )
+    public void setMainClass(String mainClass)
     {
         this.mainClass = mainClass;
     }
 
-
-    public void setClassPath( String[] classPath )
+    public void setClassPath(String[] classPath)
     {
         this.classPath = classPath;
     }
 
-
-    public void setJavaDocLocation( IPath javaDocLocation )
+    public void setJavaDocLocation(IPath javaDocLocation)
     {
         this.javaDocLocation = javaDocLocation;
     }
 
-
-    public void setSourceLocation( IPath sourceLocation )
+    public void setSourceLocation(IPath sourceLocation)
     {
         this.sourceLocation = sourceLocation;
     }
 
-
-    public void setDefaultBundleLocations( IPath[] defaultBundleLocations )
+    public void setDefaultBundleLocations(IPath[] defaultBundleLocations)
     {
         this.defaultBundleLocations = defaultBundleLocations;
     }
 
-
     public String toString()
     {
-        return "OSGiInstallType[\n" + "name=" + name + "\n" + "version=" + version + "\n" + "mainClass=" + mainClass
-            + "\n" + "classPath=" + Arrays.asList( classPath ) + "\n" + "javaDocLocation=" + javaDocLocation + "\n"
-            + "sourceLocation=" + sourceLocation + "\n" + "defaultBundleLocations="
-            + Arrays.asList( defaultBundleLocations ) + "\n" + "]";
+        return "OSGiInstallType[\n" + "name=" + name + "\n" + "version=" + version + "\n"
+            + "mainClass=" + mainClass + "\n" + "classPath=" + Arrays.asList(classPath)
+            + "\n" + "javaDocLocation=" + javaDocLocation + "\n" + "sourceLocation="
+            + sourceLocation + "\n" + "defaultBundleLocations="
+            + Arrays.asList(defaultBundleLocations) + "\n" + "]";
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/FileAdaptorFactory.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/FileAdaptorFactory.java
index dcac17f..283984c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/FileAdaptorFactory.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/FileAdaptorFactory.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.adapter;
 
-
 import org.apache.felix.sigil.common.model.ModelElementFactory;
 import org.apache.felix.sigil.common.model.ModelElementFactoryException;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
@@ -30,7 +29,6 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IAdapterFactory;
 
-
 /**
  * @author savage
  *
@@ -43,56 +41,53 @@
 
     }
 
-    private Class<?>[] types = new Class<?>[]
-        { ISigilBundle.class };
-
+    private Class<?>[] types = new Class<?>[] { ISigilBundle.class };
 
     /* (non-Javadoc)
      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
      */
     @SuppressWarnings("unchecked")
-    public Object getAdapter( Object adaptableObject, Class adapterType )
+    public Object getAdapter(Object adaptableObject, Class adapterType)
     {
         Object adapted = null;
 
-        IFile file = ( IFile ) adaptableObject;
+        IFile file = (IFile) adaptableObject;
 
-        if ( ISigilBundle.class.equals( adapterType ) )
+        if (ISigilBundle.class.equals(adapterType))
         {
-            adapted = adaptBundle( file );
+            adapted = adaptBundle(file);
         }
 
         return adapted;
     }
 
-
-    private Object adaptBundle( IFile file )
+    private Object adaptBundle(IFile file)
     {
         Object adapted = null;
         IProject project = file.getProject();
         try
         {
-            if ( SigilCore.hasProjectNature( project ) )
+            if (SigilCore.hasProjectNature(project))
             {
-                ISigilProjectModel sigil = SigilCore.create( project );
-                ISigilBundle bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
-                bundle.setParent( sigil );
+                ISigilProjectModel sigil = SigilCore.create(project);
+                ISigilBundle bundle = ModelElementFactory.getInstance().newModelElement(
+                    ISigilBundle.class);
+                bundle.setParent(sigil);
                 adapted = bundle;
             }
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to construct bundle", e );
+            SigilCore.error("Failed to construct bundle", e);
         }
-        catch ( ModelElementFactoryException e )
+        catch (ModelElementFactoryException e)
         {
-            SigilCore.error( "Failed to construct bundle", e );
+            SigilCore.error("Failed to construct bundle", e);
         }
 
         return adapted;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
      */
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/ProjectAdaptorFactory.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/ProjectAdaptorFactory.java
index 0bb9f7e..ea805cd 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/ProjectAdaptorFactory.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/ProjectAdaptorFactory.java
@@ -19,14 +19,12 @@
 
 package org.apache.felix.sigil.eclipse.internal.adapter;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IAdapterFactory;
 
-
 /**
  * @author savage
  *
@@ -34,39 +32,36 @@
 public class ProjectAdaptorFactory implements IAdapterFactory
 {
 
-    private Class<?>[] types = new Class<?>[]
-        { ISigilProjectModel.class };
-
+    private Class<?>[] types = new Class<?>[] { ISigilProjectModel.class };
 
     /* (non-Javadoc)
      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
      */
     @SuppressWarnings("unchecked")
-    public Object getAdapter( Object adaptableObject, Class adapterType )
+    public Object getAdapter(Object adaptableObject, Class adapterType)
     {
         Object adapted = null;
 
-        IProject project = ( IProject ) adaptableObject;
+        IProject project = (IProject) adaptableObject;
 
-        if ( ISigilProjectModel.class.equals( adapterType ) )
+        if (ISigilProjectModel.class.equals(adapterType))
         {
-            adapted = adaptProject( project );
+            adapted = adaptProject(project);
         }
 
         return adapted;
     }
 
-
-    private Object adaptProject( IProject project )
+    private Object adaptProject(IProject project)
     {
         try
         {
-            if ( SigilCore.isSigilProject( project ) )
+            if (SigilCore.isSigilProject(project))
             {
-                return SigilCore.create( project );
+                return SigilCore.create(project);
             }
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
@@ -74,7 +69,6 @@
         return null;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
      */
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/BuildConsole.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/BuildConsole.java
index 34eae26..9f3eba0 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/BuildConsole.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/BuildConsole.java
@@ -19,28 +19,24 @@
 
 package org.apache.felix.sigil.eclipse.internal.builders;
 
-
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.console.MessageConsole;
 import org.eclipse.ui.console.MessageConsoleStream;
 
-
 public class BuildConsole extends MessageConsole
 {
 
     private static final ImageDescriptor imageDescriptor = null;
     private MessageConsoleStream stream;
 
-
     public BuildConsole()
     {
-        super( "Sigil Build", imageDescriptor, true );
+        super("Sigil Build", imageDescriptor, true);
     }
 
-
     public synchronized MessageConsoleStream getMessageStream()
     {
-        if ( stream == null )
+        if (stream == null)
         {
             stream = newMessageStream();
         }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
index 63dbaf1..baf86a0 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.builders;
 
-
 import java.io.File;
 import java.util.Collection;
 import java.util.LinkedList;
@@ -56,26 +55,25 @@
 import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.MessageConsoleStream;
 
-
 public class SigilIncrementalProjectBuilder extends IncrementalProjectBuilder
 {
     @Override
-    protected IProject[] build( int kind, @SuppressWarnings("unchecked") Map args, IProgressMonitor monitor )
-        throws CoreException
+    protected IProject[] build(int kind, @SuppressWarnings("unchecked") Map args,
+        IProgressMonitor monitor) throws CoreException
     {
         IProject project = getProject();
 
-        if ( checkOk( project ) )
+        if (checkOk(project))
         {
-            switch ( kind )
+            switch (kind)
             {
                 case CLEAN_BUILD:
                 case FULL_BUILD:
-                    fullBuild( project, monitor );
+                    fullBuild(project, monitor);
                     break;
                 case AUTO_BUILD:
                 case INCREMENTAL_BUILD:
-                    autoBuild( project, monitor );
+                    autoBuild(project, monitor);
                     break;
             }
         }
@@ -83,66 +81,66 @@
         return null;
     }
 
-
     /**
      * @param install
      * @param project
      * @param monitor
      * @throws CoreException 
      */
-    private void autoBuild( IProject project, IProgressMonitor monitor ) throws CoreException
+    private void autoBuild(IProject project, IProgressMonitor monitor)
+        throws CoreException
     {
-        IResourceDelta delta = getDelta( project );
+        IResourceDelta delta = getDelta(project);
         final boolean[] changed = new boolean[1];
-        ISigilProjectModel sigil = SigilCore.create( project );
-        final IPath bldRoot = sigil.findBundleLocation().removeLastSegments( 1 );
+        ISigilProjectModel sigil = SigilCore.create(project);
+        final IPath bldRoot = sigil.findBundleLocation().removeLastSegments(1);
 
-        delta.accept( new IResourceDeltaVisitor()
+        delta.accept(new IResourceDeltaVisitor()
         {
-            public boolean visit( IResourceDelta delta ) throws CoreException
+            public boolean visit(IResourceDelta delta) throws CoreException
             {
-                if ( !changed[0] )
+                if (!changed[0])
                 {
                     IResource res = delta.getResource();
-                    if ( res.getType() == IResource.FILE )
+                    if (res.getType() == IResource.FILE)
                     {
-                        changed[0] = !bldRoot.isPrefixOf( res.getLocation() );
+                        changed[0] = !bldRoot.isPrefixOf(res.getLocation());
                     }
                 }
                 return !changed[0];
             }
-        } );
+        });
 
-        if ( changed[0] )
+        if (changed[0])
         {
-            doBuild( project, monitor );
+            doBuild(project, monitor);
         }
     }
 
-
     /**
      * @param install
      * @param project
      * @param monitor
      * @throws CoreException 
      */
-    private void fullBuild( IProject project, IProgressMonitor monitor ) throws CoreException
+    private void fullBuild(IProject project, IProgressMonitor monitor)
+        throws CoreException
     {
-        doBuild( project, monitor );
+        doBuild(project, monitor);
     }
 
-
-    private boolean checkOk( IProject project ) throws CoreException
+    private boolean checkOk(IProject project) throws CoreException
     {
-        IMarker[] markers = project.findMarkers( IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true,
-            IResource.DEPTH_INFINITE );
+        IMarker[] markers = project.findMarkers(
+            IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
 
-        for ( IMarker m : markers )
+        for (IMarker m : markers)
         {
-            Integer s = ( Integer ) m.getAttribute( IMarker.SEVERITY );
-            if ( s != null && s.equals( IMarker.SEVERITY_ERROR ) )
+            Integer s = (Integer) m.getAttribute(IMarker.SEVERITY);
+            if (s != null && s.equals(IMarker.SEVERITY_ERROR))
             {
-                SigilCore.log( "Skipping " + project.getName() + " build due to unresolved errors" );
+                SigilCore.log("Skipping " + project.getName()
+                    + " build due to unresolved errors");
                 return false;
             }
         }
@@ -150,58 +148,56 @@
         return true;
     }
 
-
-    private void doBuild( IProject project, IProgressMonitor monitor ) throws CoreException
+    private void doBuild(IProject project, IProgressMonitor monitor) throws CoreException
     {
-        ISigilProjectModel sigil = SigilCore.create( project );
+        ISigilProjectModel sigil = SigilCore.create(project);
         IBldProject bld = sigil.getBldProject();
 
-        File[] classpath = buildClasspath( sigil, monitor );
+        File[] classpath = buildClasspath(sigil, monitor);
 
-        String destPattern = buildDestPattern( sigil );
+        String destPattern = buildDestPattern(sigil);
 
         Properties env = new Properties();
 
-        BundleBuilder bb = new BundleBuilder( bld, classpath, destPattern, env );
+        BundleBuilder bb = new BundleBuilder(bld, classpath, destPattern, env);
 
-        for ( IBldProject.IBldBundle bundle : bld.getBundles() )
+        for (IBldProject.IBldBundle bundle : bld.getBundles())
         {
             String id = bundle.getId();
-            loginfo( "creating bundle: " + id );
+            loginfo("creating bundle: " + id);
             int nWarn = 0;
             int nErr = 0;
             String msg = "";
 
             try
             {
-                boolean modified = bb.createBundle( bundle, false, new BundleBuilder.Log()
+                boolean modified = bb.createBundle(bundle, false, new BundleBuilder.Log()
                 {
-                    public void warn( String msg )
+                    public void warn(String msg)
                     {
-                        logwarn( msg );
+                        logwarn(msg);
                     }
 
-
-                    public void verbose( String msg )
+                    public void verbose(String msg)
                     {
-                        loginfo( msg );
+                        loginfo(msg);
                     }
-                } );
+                });
                 nWarn = bb.warnings().size();
-                if ( !modified )
+                if (!modified)
                 {
                     msg = " (not modified)";
                 }
             }
-            catch ( Exception e )
+            catch (Exception e)
             {
                 List<String> errors = bb.errors();
-                if ( errors != null )
+                if (errors != null)
                 {
                     nErr = errors.size();
-                    for ( String err : errors )
+                    for (String err : errors)
                     {
-                        logerror( err );
+                        logerror(err);
                     }
                 }
                 // FELIX-1690 - error is already logged no need to throw error as this
@@ -210,124 +206,122 @@
             }
             finally
             {
-                loginfo( id + ": " + count( nErr, "error" ) + ", " + count( nWarn, "warning" ) + msg );
+                loginfo(id + ": " + count(nErr, "error") + ", " + count(nWarn, "warning")
+                    + msg);
             }
         }
     }
 
-
-    private static void loginfo( String message )
+    private static void loginfo(String message)
     {
         log("INFO: " + message);
     }
 
-    private static void logwarn( String message )
+    private static void logwarn(String message)
     {
-        log( "WARN: " + message );
+        log("WARN: " + message);
     }
 
-
-    private static void logerror( String message )
+    private static void logerror(String message)
     {
-        log( "ERROR: " + message );
+        log("ERROR: " + message);
     }
 
     private static void log(final String message)
     {
         // do this in background to avoid deadlock with ui 
-        Job job = new Job("log") {
+        Job job = new Job("log")
+        {
             @Override
             protected IStatus run(IProgressMonitor arg0)
             {
                 BuildConsole console = findConsole();
                 MessageConsoleStream stream = console.getMessageStream();
-                stream.println( message );
+                stream.println(message);
                 return Status.OK_STATUS;
             }
         };
         job.schedule();
     }
 
-
     private static BuildConsole findConsole()
     {
         BuildConsole console = null;
 
         IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
 
-        for ( IConsole c : manager.getConsoles() )
+        for (IConsole c : manager.getConsoles())
         {
-            if ( c instanceof BuildConsole )
+            if (c instanceof BuildConsole)
             {
-                console = ( BuildConsole ) c;
+                console = (BuildConsole) c;
                 break;
             }
         }
 
-        if ( console == null )
+        if (console == null)
         {
             console = new BuildConsole();
-            manager.addConsoles( new IConsole[]
-                { console } );
+            manager.addConsoles(new IConsole[] { console });
         }
 
         return console;
     }
 
-
-    private String buildDestPattern( ISigilProjectModel sigil ) throws CoreException
+    private String buildDestPattern(ISigilProjectModel sigil) throws CoreException
     {
-        IPath loc = sigil.findBundleLocation().removeLastSegments( 1 );
+        IPath loc = sigil.findBundleLocation().removeLastSegments(1);
 
         loc.toFile().mkdirs();
 
         return loc.toOSString() + File.separator + "[name].jar";
     }
 
-
-    private File[] buildClasspath( ISigilProjectModel sigil, IProgressMonitor monitor ) throws CoreException
-    {
-        LinkedList<File> files = new LinkedList<File>();
-        if ( sigil.getBundle().getClasspathEntrys().isEmpty() ) {
-            IClasspathEntry[] entries = sigil.getJavaModel().getResolvedClasspath(true);
-            for ( IClasspathEntry cp : entries )
-            {
-                convert( cp, sigil, files );
-            }
-        }
-        else {
-            buildLocalClasspath( sigil, files );
-            buildExternalClasspath( sigil, files, monitor );
-        }
-        return files.toArray( new File[files.size()] );            
-    }
-
-
-    private void buildExternalClasspath( ISigilProjectModel sigil, List<File> files, IProgressMonitor monitor )
+    private File[] buildClasspath(ISigilProjectModel sigil, IProgressMonitor monitor)
         throws CoreException
     {
-        Collection<IClasspathEntry> entries = sigil.findExternalClasspath( monitor );
-
-        for ( IClasspathEntry cp : entries )
+        LinkedList<File> files = new LinkedList<File>();
+        if (sigil.getBundle().getClasspathEntrys().isEmpty())
         {
-            convert( cp, sigil, files );
+            IClasspathEntry[] entries = sigil.getJavaModel().getResolvedClasspath(true);
+            for (IClasspathEntry cp : entries)
+            {
+                convert(cp, sigil, files);
+            }
+        }
+        else
+        {
+            buildLocalClasspath(sigil, files);
+            buildExternalClasspath(sigil, files, monitor);
+        }
+        return files.toArray(new File[files.size()]);
+    }
+
+    private void buildExternalClasspath(ISigilProjectModel sigil, List<File> files,
+        IProgressMonitor monitor) throws CoreException
+    {
+        Collection<IClasspathEntry> entries = sigil.findExternalClasspath(monitor);
+
+        for (IClasspathEntry cp : entries)
+        {
+            convert(cp, sigil, files);
         }
     }
 
-
-    private void buildLocalClasspath( ISigilProjectModel sigil, List<File> files ) throws CoreException
+    private void buildLocalClasspath(ISigilProjectModel sigil, List<File> files)
+        throws CoreException
     {
-        Collection<IClasspathEntry> entries = JavaHelper.findClasspathEntries( sigil.getBundle() );
-        for ( IClasspathEntry cp : entries )
+        Collection<IClasspathEntry> entries = JavaHelper.findClasspathEntries(sigil.getBundle());
+        for (IClasspathEntry cp : entries)
         {
-            convert( cp, sigil, files );
+            convert(cp, sigil, files);
         }
     }
 
-
-    private void convert( IClasspathEntry cp, ISigilProjectModel sigil, List<File> files ) throws CoreException
+    private void convert(IClasspathEntry cp, ISigilProjectModel sigil, List<File> files)
+        throws CoreException
     {
-        switch ( cp.getEntryKind() )
+        switch (cp.getEntryKind())
         {
             case IClasspathEntry.CPE_PROJECT:
             {
@@ -350,84 +344,85 @@
         }
     }
 
-
     private void convertVariable(IClasspathEntry cp, List<File> files)
     {
-        cp = JavaCore.getResolvedClasspathEntry( cp );
-        if ( cp != null )
+        cp = JavaCore.getResolvedClasspathEntry(cp);
+        if (cp != null)
         {
             IPath p = cp.getPath();
-            files.add( p.toFile() );
+            files.add(p.toFile());
         }
     }
 
-
-    private void convertLibrary(ISigilProjectModel sigil, IClasspathEntry cp, List<File> files)
+    private void convertLibrary(ISigilProjectModel sigil, IClasspathEntry cp,
+        List<File> files)
     {
         IPath p = cp.getPath();
 
-        IProject project = sigil.getProject().getWorkspace().getRoot().getProject( p.segment( 0 ) );
-        if ( project.exists() )
+        IProject project = sigil.getProject().getWorkspace().getRoot().getProject(
+            p.segment(0));
+        if (project.exists())
         {
-            p = project.getLocation().append( p.removeFirstSegments( 1 ) );
+            p = project.getLocation().append(p.removeFirstSegments(1));
         }
 
-        files.add( p.toFile() );
+        files.add(p.toFile());
     }
 
-
-    private void convertSource(ISigilProjectModel sigil, IClasspathEntry cp, List<File> files) throws JavaModelException
+    private void convertSource(ISigilProjectModel sigil, IClasspathEntry cp,
+        List<File> files) throws JavaModelException
     {
-        IPath path = cp.getOutputLocation() == null ? sigil.getJavaModel().getOutputLocation() : cp
-            .getOutputLocation();
-        IFolder buildFolder = sigil.getProject().getFolder( path.removeFirstSegments( 1 ) );
-        if ( buildFolder.exists() )
+        IPath path = cp.getOutputLocation() == null ? sigil.getJavaModel().getOutputLocation()
+            : cp.getOutputLocation();
+        IFolder buildFolder = sigil.getProject().getFolder(path.removeFirstSegments(1));
+        if (buildFolder.exists())
         {
-            files.add( buildFolder.getLocation().toFile() );
+            files.add(buildFolder.getLocation().toFile());
         }
     }
 
-
-    private void convertProject(IClasspathEntry cp, List<File> files) throws CoreException
+    private void convertProject(IClasspathEntry cp, List<File> files)
+        throws CoreException
     {
-        IProject p = findProject( cp.getPath() );
-        ISigilProjectModel project = SigilCore.create( p );
-        if ( project.getBundle().getClasspathEntrys().isEmpty() ) {
+        IProject p = findProject(cp.getPath());
+        ISigilProjectModel project = SigilCore.create(p);
+        if (project.getBundle().getClasspathEntrys().isEmpty())
+        {
             // ew this is pretty messy - if a dependent bundle specifies it's dependencies
             // via package statements vs source directories then we need to add
             // the classpath path of that bundle
-            for ( IClasspathEntry rp : project.getJavaModel().getResolvedClasspath(true) ) {
-                convert( rp, project, files );
+            for (IClasspathEntry rp : project.getJavaModel().getResolvedClasspath(true))
+            {
+                convert(rp, project, files);
             }
         }
-        else {
-            for ( String scp : project.getBundle().getClasspathEntrys() )
+        else
+        {
+            for (String scp : project.getBundle().getClasspathEntrys())
             {
-                IClasspathEntry jcp = project.getJavaModel().decodeClasspathEntry( scp );
-                convert( jcp, project, files );
+                IClasspathEntry jcp = project.getJavaModel().decodeClasspathEntry(scp);
+                convert(jcp, project, files);
             }
         }
     }
 
-
-    private IProject findProject( IPath path ) throws CoreException
+    private IProject findProject(IPath path) throws CoreException
     {
         IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
-        for ( IProject p : root.getProjects() )
+        for (IProject p : root.getProjects())
         {
             IPath projectPath = p.getFullPath();
-            if ( projectPath.equals( path ) )
+            if (projectPath.equals(path))
             {
                 return p;
             }
         }
 
-        throw SigilCore.newCoreException( "No such project " + path, null );
+        throw SigilCore.newCoreException("No such project " + path, null);
     }
 
-
-    private String count( int count, String msg )
+    private String count(int count, String msg)
     {
-        return count + " " + msg + ( count == 1 ? "" : "s" );
+        return count + " " + msg + (count == 1 ? "" : "s");
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/install/OSGiInstallManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/install/OSGiInstallManager.java
index 40748c6..e50dbf8 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/install/OSGiInstallManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/install/OSGiInstallManager.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.install;
 
-
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -49,7 +48,6 @@
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.dialogs.PreferencesUtil;
 
-
 public class OSGiInstallManager implements IOSGiInstallManager, IPropertyChangeListener
 {
     private static final int NORMAL_PRIORITY = 0;
@@ -63,195 +61,185 @@
 
     private boolean initialised;
 
-
-    public IOSGiInstall findInstall( String id )
+    public IOSGiInstall findInstall(String id)
     {
         init();
-        return idToInstall.get( id );
+        return idToInstall.get(id);
     }
 
-
     public String[] getInstallIDs()
     {
         init();
-        return idToInstall.keySet().toArray( new String[idToInstall.size()] );
+        return idToInstall.keySet().toArray(new String[idToInstall.size()]);
     }
 
-
     public IOSGiInstall[] getInstalls()
     {
         init();
-        return idToInstall.values().toArray( new IOSGiInstall[idToInstall.size()] );
+        return idToInstall.values().toArray(new IOSGiInstall[idToInstall.size()]);
     }
 
-
     public IOSGiInstall getDefaultInstall()
     {
         init();
-        return findInstall( defaultId );
+        return findInstall(defaultId);
     }
 
-
-    public IOSGiInstallType findInstallType( String location )
+    public IOSGiInstallType findInstallType(String location)
     {
         IOSGiInstallType type = null;
 
         try
         {
-            IOSGiInstall install = buildInstall( "tmp", new Path( location ) );
+            IOSGiInstall install = buildInstall("tmp", new Path(location));
             type = install == null ? null : install.getType();
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to build install", e );
+            SigilCore.error("Failed to build install", e);
         }
 
         return type;
     }
 
-
-    public void propertyChange( PropertyChangeEvent event )
+    public void propertyChange(PropertyChangeEvent event)
     {
-        synchronized ( this )
+        synchronized (this)
         {
-            if ( event.getProperty().equals( SigilCore.OSGI_INSTALLS ) )
+            if (event.getProperty().equals(SigilCore.OSGI_INSTALLS))
             {
                 clearInstalls();
-                String val = ( String ) event.getNewValue();
-                addInstalls( val );
+                String val = (String) event.getNewValue();
+                addInstalls(val);
             }
-            else if ( event.getProperty().equals( SigilCore.OSGI_DEFAULT_INSTALL_ID ) )
+            else if (event.getProperty().equals(SigilCore.OSGI_DEFAULT_INSTALL_ID))
             {
-                defaultId = ( String ) event.getNewValue();
+                defaultId = (String) event.getNewValue();
             }
         }
     }
 
-
     private void init()
     {
         boolean show = false;
 
         IPreferenceStore prefs = getPreferenceStore();
 
-        synchronized ( this )
+        synchronized (this)
         {
-            if ( !initialised )
+            if (!initialised)
             {
                 initialised = true;
 
-                prefs.addPropertyChangeListener( this );
+                prefs.addPropertyChangeListener(this);
 
-                String val = prefs.getString( SigilCore.OSGI_INSTALLS );
+                String val = prefs.getString(SigilCore.OSGI_INSTALLS);
 
-                boolean noAsk = prefs.getBoolean( SigilCore.PREFERENCES_NOASK_OSGI_INSTALL );
-                if ( val == null || val.trim().length() == 0 )
+                boolean noAsk = prefs.getBoolean(SigilCore.PREFERENCES_NOASK_OSGI_INSTALL);
+                if (val == null || val.trim().length() == 0)
                 {
                     show = !noAsk;
                 }
                 else
                 {
-                    addInstalls( val );
-                    defaultId = prefs.getString( SigilCore.OSGI_DEFAULT_INSTALL_ID );
+                    addInstalls(val);
+                    defaultId = prefs.getString(SigilCore.OSGI_DEFAULT_INSTALL_ID);
                 }
             }
         }
 
-        if ( show )
+        if (show)
         {
-            showInstallPrefs( prefs );
+            showInstallPrefs(prefs);
         }
     }
 
-
-    private void addInstalls( String prop )
+    private void addInstalls(String prop)
     {
-        if ( prop != null && prop.trim().length() > 0 )
+        if (prop != null && prop.trim().length() > 0)
         {
             IPreferenceStore prefs = getPreferenceStore();
 
-            for ( String id : prop.split( "," ) )
+            for (String id : prop.split(","))
             {
-                String path = prefs.getString( SigilCore.OSGI_INSTALL_PREFIX + id );
-                addInstall( id, new Path( path ) );
+                String path = prefs.getString(SigilCore.OSGI_INSTALL_PREFIX + id);
+                addInstall(id, new Path(path));
             }
         }
     }
 
-
     private IPreferenceStore getPreferenceStore()
     {
         return SigilCore.getDefault().getPreferenceStore();
     }
 
-
-    private void showInstallPrefs( final IPreferenceStore prefs )
+    private void showInstallPrefs(final IPreferenceStore prefs)
     {
         Runnable r = new Runnable()
         {
             public void run()
             {
-                MessageDialogWithToggle questionDialog = MessageDialogWithToggle.openYesNoQuestion( PlatformUI
-                    .getWorkbench().getActiveWorkbenchWindow().getShell(), "Sigil Configuration",
+                MessageDialogWithToggle questionDialog = MessageDialogWithToggle.openYesNoQuestion(
+                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+                    "Sigil Configuration",
                     "Missing OSGi installation. Open preferences to configure it now?",
-                    "Do not show this message again", false, null, null );
-                prefs.setValue( SigilCore.PREFERENCES_NOASK_OSGI_INSTALL, questionDialog.getToggleState() );
-                if ( questionDialog.getReturnCode() == IDialogConstants.YES_ID )
+                    "Do not show this message again", false, null, null);
+                prefs.setValue(SigilCore.PREFERENCES_NOASK_OSGI_INSTALL,
+                    questionDialog.getToggleState());
+                if (questionDialog.getReturnCode() == IDialogConstants.YES_ID)
                 {
-                    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( null,
-                        SigilCore.OSGI_INSTALLS_PREFERENCES_ID, null, null );
+                    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+                        null, SigilCore.OSGI_INSTALLS_PREFERENCES_ID, null, null);
                     dialog.open();
                 }
             }
         };
         Display d = Display.getCurrent();
-        if ( d == null )
+        if (d == null)
         {
             d = Display.getDefault();
-            d.asyncExec( r );
+            d.asyncExec(r);
         }
         else
         {
-            d.syncExec( r );
+            d.syncExec(r);
         }
     }
 
-
-    private IOSGiInstall addInstall( String id, IPath path )
+    private IOSGiInstall addInstall(String id, IPath path)
     {
-        IOSGiInstall install = pathToinstall.get( path );
+        IOSGiInstall install = pathToinstall.get(path);
 
-        if ( install == null )
+        if (install == null)
         {
             try
             {
-                install = buildInstall( id, path );
-                if ( install != null )
+                install = buildInstall(id, path);
+                if (install != null)
                 {
-                    pathToinstall.put( path, install );
-                    idToInstall.put( install.getId(), install );
+                    pathToinstall.put(path, install);
+                    idToInstall.put(install.getId(), install);
                 }
             }
-            catch ( CoreException e )
+            catch (CoreException e)
             {
-                SigilCore.error( "Failed to build install for " + path, e );
+                SigilCore.error("Failed to build install for " + path, e);
             }
         }
 
         return install;
     }
 
-
-    private IOSGiInstall buildInstall( String id, IPath path ) throws CoreException
+    private IOSGiInstall buildInstall(String id, IPath path) throws CoreException
     {
         initBuilders();
         IOSGiInstall install = null;
 
-        for ( IOSGiInstallBuilder b : builders )
+        for (IOSGiInstallBuilder b : builders)
         {
-            install = b.build( id, path );
+            install = b.build(id, path);
 
-            if ( install != null )
+            if (install != null)
             {
                 break;
             }
@@ -260,45 +248,43 @@
         return install;
     }
 
-
     private void clearInstalls()
     {
         idToInstall.clear();
         pathToinstall.clear();
     }
 
-
     private void initBuilders()
     {
-        synchronized ( builders )
+        synchronized (builders)
         {
-            if ( builders.isEmpty() )
+            if (builders.isEmpty())
             {
                 final HashMap<IOSGiInstallBuilder, Integer> tmp = new HashMap<IOSGiInstallBuilder, Integer>();
 
                 IExtensionRegistry registry = Platform.getExtensionRegistry();
-                IExtensionPoint p = registry.getExtensionPoint( SigilCore.INSTALL_BUILDER_EXTENSION_POINT_ID );
-                for ( IExtension e : p.getExtensions() )
+                IExtensionPoint p = registry.getExtensionPoint(SigilCore.INSTALL_BUILDER_EXTENSION_POINT_ID);
+                for (IExtension e : p.getExtensions())
                 {
-                    for ( IConfigurationElement c : e.getConfigurationElements() )
+                    for (IConfigurationElement c : e.getConfigurationElements())
                     {
-                        createBuilderFromElement( c, tmp );
+                        createBuilderFromElement(c, tmp);
                     }
                 }
 
-                builders = new LinkedList<IOSGiInstallBuilder>( tmp.keySet() );
-                Collections.sort( builders, new Comparator<IOSGiInstallBuilder>()
+                builders = new LinkedList<IOSGiInstallBuilder>(tmp.keySet());
+                Collections.sort(builders, new Comparator<IOSGiInstallBuilder>()
                 {
-                    public int compare( IOSGiInstallBuilder o1, IOSGiInstallBuilder o2 )
+                    public int compare(IOSGiInstallBuilder o1, IOSGiInstallBuilder o2)
                     {
-                        int p1 = tmp.get( o1 );
-                        int p2 = tmp.get( o2 );
+                        int p1 = tmp.get(o1);
+                        int p2 = tmp.get(o2);
 
-                        if ( p1 == p2 )
+                        if (p1 == p2)
                         {
                             return 0;
                         }
-                        else if ( p1 > p2 )
+                        else if (p1 > p2)
                         {
                             return -1;
                         }
@@ -307,38 +293,37 @@
                             return 1;
                         }
                     }
-                } );
+                });
             }
         }
     }
 
-
-    private void createBuilderFromElement( IConfigurationElement c, Map<IOSGiInstallBuilder, Integer> builder )
+    private void createBuilderFromElement(IConfigurationElement c,
+        Map<IOSGiInstallBuilder, Integer> builder)
     {
         try
         {
-            IOSGiInstallBuilder b = ( IOSGiInstallBuilder ) c.createExecutableExtension( "class" );
-            int priority = parsePriority( c );
-            builder.put( b, priority );
+            IOSGiInstallBuilder b = (IOSGiInstallBuilder) c.createExecutableExtension("class");
+            int priority = parsePriority(c);
+            builder.put(b, priority);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to create builder", e );
+            SigilCore.error("Failed to create builder", e);
         }
     }
 
-
-    private int parsePriority( IConfigurationElement c )
+    private int parsePriority(IConfigurationElement c)
     {
-        String str = c.getAttribute( "priority" );
+        String str = c.getAttribute("priority");
 
-        if ( str == null )
+        if (str == null)
         {
             return NORMAL_PRIORITY;
         }
         else
         {
-            return Integer.parseInt( str );
+            return Integer.parseInt(str);
         }
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilModelRoot.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilModelRoot.java
index cd9ef1b..7188cfe 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilModelRoot.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilModelRoot.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.model.project;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
@@ -47,146 +46,152 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 
-
 public class SigilModelRoot implements ISigilModelRoot
 {
     public List<ISigilProjectModel> getProjects()
     {
         IProject[] all = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-        ArrayList<ISigilProjectModel> projects = new ArrayList<ISigilProjectModel>( all.length );
-        for ( IProject p : all )
+        ArrayList<ISigilProjectModel> projects = new ArrayList<ISigilProjectModel>(
+            all.length);
+        for (IProject p : all)
         {
             try
             {
-                if ( p.isOpen() && p.hasNature( SigilCore.NATURE_ID ) )
+                if (p.isOpen() && p.hasNature(SigilCore.NATURE_ID))
                 {
-                    ISigilProjectModel n = SigilCore.create( p );
-                    projects.add( n );
+                    ISigilProjectModel n = SigilCore.create(p);
+                    projects.add(n);
                 }
             }
-            catch ( CoreException e )
+            catch (CoreException e)
             {
-                SigilCore.error( "Failed to build model element", e );
+                SigilCore.error("Failed to build model element", e);
             }
         }
 
         return projects;
     }
 
-
-    public Set<ISigilProjectModel> resolveDependentProjects( Collection<ICapabilityModelElement> caps, IProgressMonitor monitor )
+    public Set<ISigilProjectModel> resolveDependentProjects(
+        Collection<ICapabilityModelElement> caps, IProgressMonitor monitor)
     {
         final HashSet<ISigilProjectModel> dependents = new HashSet<ISigilProjectModel>();
 
-        for ( final ISigilProjectModel n : getProjects() )
+        for (final ISigilProjectModel n : getProjects())
         {
-            for (final ICapabilityModelElement cap : caps ) {
+            for (final ICapabilityModelElement cap : caps)
+            {
                 final ISigilProjectModel sigil = cap.getAncestor(ISigilProjectModel.class);
-                
+
                 n.visit(new IModelWalker()
                 {
                     public boolean visit(IModelElement element)
                     {
-                        if ( element instanceof IRequirementModelElement ) {
+                        if (element instanceof IRequirementModelElement)
+                        {
                             IRequirementModelElement req = (IRequirementModelElement) element;
-                            if ( req.accepts(cap) ) {
+                            if (req.accepts(cap))
+                            {
                                 dependents.add(n);
                                 return false;
                             }
                         }
-                        else if ( element instanceof ILibraryImport ) {
+                        else if (element instanceof ILibraryImport)
+                        {
                             ILibraryImport l = (ILibraryImport) element;
-                            ILibrary lib = SigilCore.getRepositoryManager( sigil ).resolveLibrary( l );
+                            ILibrary lib = SigilCore.getRepositoryManager(sigil).resolveLibrary(
+                                l);
 
-                            if ( lib != null )
+                            if (lib != null)
                             {
-                                for ( IPackageImport i : lib.getImports() )
+                                for (IPackageImport i : lib.getImports())
                                 {
-                                    if ( i.accepts(cap))
+                                    if (i.accepts(cap))
                                     {
-                                        dependents.add( n );
+                                        dependents.add(n);
                                     }
                                 }
                             }
                             else
                             {
-                                SigilCore.error( "No library found for " + l );
+                                SigilCore.error("No library found for " + l);
                             }
                         }
                         return true;
                     }
                 });
             }
-//            if ( !sigil.equals( n ) )
-//            {
-//                for ( IPackageExport pe : sigil.getBundle().getBundleInfo().getExports() )
-//                {
-//                    for ( IPackageImport i : n.getBundle().getBundleInfo().getImports() )
-//                    {
-//                        if ( pe.getPackageName().equals( i.getPackageName() )
-//                            && i.getVersions().contains( pe.getVersion() ) )
-//                        {
-//                            dependents.add( n );
-//                        }
-//                    }
-//
-//                    for ( ILibraryImport l : n.getBundle().getBundleInfo().getLibraryImports() )
-//                    {
-//                        ILibrary lib = SigilCore.getRepositoryManager( sigil ).resolveLibrary( l );
-//
-//                        if ( lib != null )
-//                        {
-//                            for ( IPackageImport i : lib.getImports() )
-//                            {
-//                                if ( pe.getPackageName().equals( i.getPackageName() )
-//                                    && i.getVersions().contains( pe.getVersion() ) )
-//                                {
-//                                    dependents.add( n );
-//                                }
-//                            }
-//                        }
-//                        else
-//                        {
-//                            SigilCore.error( "No library found for " + l );
-//                        }
-//                    }
-//                }
-//
-//                for ( IRequiredBundle r : n.getBundle().getBundleInfo().getRequiredBundles() )
-//                {
-//                    if ( sigil.getSymbolicName().equals( r.getSymbolicName() )
-//                        && r.getVersions().contains( sigil.getVersion() ) )
-//                    {
-//                        dependents.add( n );
-//                    }
-//                }
-//            }
+            //            if ( !sigil.equals( n ) )
+            //            {
+            //                for ( IPackageExport pe : sigil.getBundle().getBundleInfo().getExports() )
+            //                {
+            //                    for ( IPackageImport i : n.getBundle().getBundleInfo().getImports() )
+            //                    {
+            //                        if ( pe.getPackageName().equals( i.getPackageName() )
+            //                            && i.getVersions().contains( pe.getVersion() ) )
+            //                        {
+            //                            dependents.add( n );
+            //                        }
+            //                    }
+            //
+            //                    for ( ILibraryImport l : n.getBundle().getBundleInfo().getLibraryImports() )
+            //                    {
+            //                        ILibrary lib = SigilCore.getRepositoryManager( sigil ).resolveLibrary( l );
+            //
+            //                        if ( lib != null )
+            //                        {
+            //                            for ( IPackageImport i : lib.getImports() )
+            //                            {
+            //                                if ( pe.getPackageName().equals( i.getPackageName() )
+            //                                    && i.getVersions().contains( pe.getVersion() ) )
+            //                                {
+            //                                    dependents.add( n );
+            //                                }
+            //                            }
+            //                        }
+            //                        else
+            //                        {
+            //                            SigilCore.error( "No library found for " + l );
+            //                        }
+            //                    }
+            //                }
+            //
+            //                for ( IRequiredBundle r : n.getBundle().getBundleInfo().getRequiredBundles() )
+            //                {
+            //                    if ( sigil.getSymbolicName().equals( r.getSymbolicName() )
+            //                        && r.getVersions().contains( sigil.getVersion() ) )
+            //                    {
+            //                        dependents.add( n );
+            //                    }
+            //                }
+            //            }
         }
 
         return dependents;
     }
 
-
-    public Collection<ISigilBundle> resolveBundles( ISigilProjectModel sigil, IModelElement element,
-        boolean includeOptional, IProgressMonitor monitor ) throws CoreException
+    public Collection<ISigilBundle> resolveBundles(ISigilProjectModel sigil,
+        IModelElement element, boolean includeOptional, IProgressMonitor monitor)
+        throws CoreException
     {
         int options = ResolutionConfig.INCLUDE_DEPENDENTS;
-        if ( includeOptional )
+        if (includeOptional)
         {
             options |= ResolutionConfig.INCLUDE_OPTIONAL;
         }
 
-        ResolutionConfig config = new ResolutionConfig( options );
+        ResolutionConfig config = new ResolutionConfig(options);
         try
         {
-            IBundleResolver resolver = SigilCore.getRepositoryManager( sigil ).getBundleResolver();
-            IResolution resolution = resolver.resolve( element, config, new ResolutionMonitorAdapter( monitor ) );
-            resolution.synchronize( monitor );
+            IBundleResolver resolver = SigilCore.getRepositoryManager(sigil).getBundleResolver();
+            IResolution resolution = resolver.resolve(element, config,
+                new ResolutionMonitorAdapter(monitor));
+            resolution.synchronize(monitor);
             return resolution.getBundles();
         }
-        catch ( ResolutionException e )
+        catch (ResolutionException e)
         {
-            throw SigilCore.newCoreException( e.getMessage(), e );
+            throw SigilCore.newCoreException(e.getMessage(), e);
         }
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
index f00900e..2530f90 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.model.project;
 
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -83,7 +82,6 @@
 import org.osgi.framework.Version;
 import org.osgi.service.prefs.Preferences;
 
-
 /**
  * @author dave
  *
@@ -106,94 +104,104 @@
 
     public SigilProject()
     {
-        super( "Sigil Project" );
+        super("Sigil Project");
     }
 
-
-    public SigilProject( IProject project ) throws CoreException
+    public SigilProject(IProject project) throws CoreException
     {
         this();
         this.project = project;
-        bldProjectFile = project.getFile( new Path( SigilCore.SIGIL_PROJECT_FILE ) );
+        bldProjectFile = project.getFile(new Path(SigilCore.SIGIL_PROJECT_FILE));
     }
-    
 
-    public void save( IProgressMonitor monitor ) throws CoreException
+    public void save(IProgressMonitor monitor) throws CoreException
     {
         save(monitor, true);
     }
-    
-    public void save( IProgressMonitor monitor, boolean rebuildDependencies ) throws CoreException
-    {
-        SubMonitor progress = SubMonitor.convert( monitor, 1000 );
 
-        bldProjectFile.setContents( buildContents(), IFile.KEEP_HISTORY, progress.newChild( 10 ) );
-     
-        if ( rebuildDependencies ) {
+    public void save(IProgressMonitor monitor, boolean rebuildDependencies)
+        throws CoreException
+    {
+        SubMonitor progress = SubMonitor.convert(monitor, 1000);
+
+        bldProjectFile.setContents(buildContents(), IFile.KEEP_HISTORY,
+            progress.newChild(10));
+
+        if (rebuildDependencies)
+        {
             rebuildDependencies(progress.newChild(900));
         }
     }
 
-    public void rebuildDependencies(IProgressMonitor monitor) throws CoreException {
-        SubMonitor progress = SubMonitor.convert( monitor, 1000 );
+    public void rebuildDependencies(IProgressMonitor monitor) throws CoreException
+    {
+        SubMonitor progress = SubMonitor.convert(monitor, 1000);
 
-        HashSet<ICapabilityModelElement> changes = new HashSet<ICapabilityModelElement>(lastCaps);
-        
+        HashSet<ICapabilityModelElement> changes = new HashSet<ICapabilityModelElement>(
+            lastCaps);
+
         LinkedList<IRequirementModelElement> reqs = new LinkedList<IRequirementModelElement>();
         LinkedList<ICapabilityModelElement> caps = new LinkedList<ICapabilityModelElement>();
-        
+
         checkChanges(progress.newChild(100), reqs, caps);
-        
+
         boolean reqsChanged;
         boolean capsChanged;
-        
-        synchronized(this) {
+
+        synchronized (this)
+        {
             reqsChanged = isRequirementsChanged(reqs);
             capsChanged = isCapabilitiesChanged(caps);
         }
-        
-        if ( reqsChanged ) {
+
+        if (reqsChanged)
+        {
             processRequirementsChanges(progress.newChild(600));
             SigilCore.rebuild(this, progress.newChild(50));
         }
-        
-        progress.setWorkRemaining( 250 );
 
-        if ( capsChanged ) {
+        progress.setWorkRemaining(250);
+
+        if (capsChanged)
+        {
             changes.addAll(caps);
-            SigilCore.rebuildBundleDependencies( this, changes, progress.newChild( 250 ) );
-        }        
+            SigilCore.rebuildBundleDependencies(this, changes, progress.newChild(250));
+        }
     }
-    
-    public void flushDependencyState() {
-        synchronized(this) {
+
+    public void flushDependencyState()
+    {
+        synchronized (this)
+        {
             lastReqs.clear();
         }
     }
-    
-    private void processRequirementsChanges(IProgressMonitor monitor) throws CoreException 
+
+    private void processRequirementsChanges(IProgressMonitor monitor)
+        throws CoreException
     {
-        SubMonitor progress = SubMonitor.convert( monitor, 100 );
-        
-        IRepositoryManager manager = SigilCore.getRepositoryManager( this );
-        ResolutionConfig config = new ResolutionConfig( ResolutionConfig.INCLUDE_OPTIONAL | ResolutionConfig.IGNORE_ERRORS );
+        SubMonitor progress = SubMonitor.convert(monitor, 100);
+
+        IRepositoryManager manager = SigilCore.getRepositoryManager(this);
+        ResolutionConfig config = new ResolutionConfig(ResolutionConfig.INCLUDE_OPTIONAL
+            | ResolutionConfig.IGNORE_ERRORS);
 
         try
         {
-            IResolution resolution = manager.getBundleResolver().resolve( this, config,
-                new ResolutionMonitorAdapter( progress.newChild( 20 ) ) );
-            
+            IResolution resolution = manager.getBundleResolver().resolve(this, config,
+                new ResolutionMonitorAdapter(progress.newChild(20)));
+
             markProblems(resolution);
-            
+
             // pull remote bundles from repositories to be added to classpath
-            if ( !resolution.isSynchronized() )
+            if (!resolution.isSynchronized())
             {
-                resolution.synchronize( progress.newChild( 80 ) );
+                resolution.synchronize(progress.newChild(80));
             }
         }
-        catch ( ResolutionException e )
+        catch (ResolutionException e)
         {
-            throw SigilCore.newCoreException( "Failed to resolve dependencies", e );
+            throw SigilCore.newCoreException("Failed to resolve dependencies", e);
         }
     }
 
@@ -201,27 +209,26 @@
     {
         try
         {
-            getProject().deleteMarkers( SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true,
-                IResource.DEPTH_ONE );
+            getProject().deleteMarkers(SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true,
+                IResource.DEPTH_ONE);
 
             // Find missing imports
             Collection<IPackageImport> imports = getBundle().getBundleInfo().getImports();
-            for ( IPackageImport pkgImport : imports )
+            for (IPackageImport pkgImport : imports)
             {
-                if ( resolution.getProvider( pkgImport ) == null )
+                if (resolution.getProvider(pkgImport) == null)
                 {
-                    markMissingImport( pkgImport, getProject() );
+                    markMissingImport(pkgImport, getProject());
                 }
             }
 
             // Find missing required bundles
-            Collection<IRequiredBundle> requiredBundles = getBundle().getBundleInfo()
-            .getRequiredBundles();
-            for ( IRequiredBundle requiredBundle : requiredBundles )
+            Collection<IRequiredBundle> requiredBundles = getBundle().getBundleInfo().getRequiredBundles();
+            for (IRequiredBundle requiredBundle : requiredBundles)
             {
-                if ( resolution.getProvider( requiredBundle ) == null )
+                if (resolution.getProvider(requiredBundle) == null)
                 {
-                    markMissingRequiredBundle( requiredBundle, getProject() );
+                    markMissingRequiredBundle(requiredBundle, getProject());
                 }
             }
         }
@@ -231,30 +238,35 @@
         }
     }
 
-    private void checkChanges(IProgressMonitor monitor, final List<IRequirementModelElement> reqs, final List<ICapabilityModelElement> caps)
+    private void checkChanges(IProgressMonitor monitor,
+        final List<IRequirementModelElement> reqs,
+        final List<ICapabilityModelElement> caps)
     {
         visit(new IModelWalker()
-        { 
+        {
             public boolean visit(IModelElement element)
             {
-                if ( element instanceof IRequirementModelElement ) {
+                if (element instanceof IRequirementModelElement)
+                {
                     reqs.add((IRequirementModelElement) element);
                 }
-                else if ( element instanceof ICapabilityModelElement ) {
+                else if (element instanceof ICapabilityModelElement)
+                {
                     // also calculate uses during this pass to save multi pass on model
-                    if ( element instanceof IPackageExport )
+                    if (element instanceof IPackageExport)
                     {
-                        IPackageExport pe = ( IPackageExport ) element;
+                        IPackageExport pe = (IPackageExport) element;
                         try
                         {
-                            pe.setUses( Arrays.asList( JavaHelper.findUses( pe.getPackageName(), SigilProject.this ) ) );
+                            pe.setUses(Arrays.asList(JavaHelper.findUses(
+                                pe.getPackageName(), SigilProject.this)));
                         }
-                        catch ( CoreException e )
+                        catch (CoreException e)
                         {
-                            SigilCore.error( "Failed to build uses list for " + pe, e );
+                            SigilCore.error("Failed to build uses list for " + pe, e);
                         }
                     }
-                    
+
                     caps.add((ICapabilityModelElement) element);
                 }
                 return true;
@@ -262,13 +274,14 @@
         });
     }
 
-
     private boolean isRequirementsChanged(List<IRequirementModelElement> dependencies)
     {
-        if ( lastReqs.equals(dependencies) ) {
+        if (lastReqs.equals(dependencies))
+        {
             return false;
         }
-        else {
+        else
+        {
             lastReqs = dependencies;
             return true;
         }
@@ -276,38 +289,45 @@
 
     private boolean isCapabilitiesChanged(List<ICapabilityModelElement> capabilites)
     {
-        if ( lastCaps.equals(capabilites) ) {
+        if (lastCaps.equals(capabilites))
+        {
             return false;
         }
-        else {
+        else
+        {
             lastCaps = capabilites;
             return true;
         }
     }
 
-    private static void markMissingImport( IPackageImport pkgImport, IProject project ) throws CoreException
+    private static void markMissingImport(IPackageImport pkgImport, IProject project)
+        throws CoreException
     {
-        IMarker marker = project.getProject().createMarker( SigilCore.MARKER_UNRESOLVED_IMPORT_PACKAGE );
-        marker.setAttribute( "element", pkgImport.getPackageName() );
-        marker.setAttribute( "versionRange", pkgImport.getVersions().toString() );
-        marker.setAttribute( IMarker.MESSAGE, "Cannot resolve imported package \"" + pkgImport.getPackageName()
-            + "\" with version range " + pkgImport.getVersions() );
-        marker.setAttribute( IMarker.SEVERITY, pkgImport.isOptional() ? IMarker.SEVERITY_WARNING
-            : IMarker.SEVERITY_ERROR );
-        marker.setAttribute( IMarker.PRIORITY, IMarker.PRIORITY_HIGH );
+        IMarker marker = project.getProject().createMarker(
+            SigilCore.MARKER_UNRESOLVED_IMPORT_PACKAGE);
+        marker.setAttribute("element", pkgImport.getPackageName());
+        marker.setAttribute("versionRange", pkgImport.getVersions().toString());
+        marker.setAttribute(IMarker.MESSAGE, "Cannot resolve imported package \""
+            + pkgImport.getPackageName() + "\" with version range "
+            + pkgImport.getVersions());
+        marker.setAttribute(IMarker.SEVERITY,
+            pkgImport.isOptional() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR);
+        marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
     }
 
-
-    private static void markMissingRequiredBundle( IRequiredBundle req, IProject project ) throws CoreException
+    private static void markMissingRequiredBundle(IRequiredBundle req, IProject project)
+        throws CoreException
     {
-        IMarker marker = project.getProject().createMarker( SigilCore.MARKER_UNRESOLVED_REQUIRE_BUNDLE );
-        marker.setAttribute( "element", req.getSymbolicName() );
-        marker.setAttribute( "versionRange", req.getVersions().toString() );
-        marker.setAttribute( IMarker.MESSAGE, "Cannot resolve required bundle \"" + req.getSymbolicName()
-            + "\" with version range " + req.getVersions() );
-        marker.setAttribute( IMarker.SEVERITY, req.isOptional() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR );
-        marker.setAttribute( IMarker.PRIORITY, IMarker.PRIORITY_HIGH );
-    }    
+        IMarker marker = project.getProject().createMarker(
+            SigilCore.MARKER_UNRESOLVED_REQUIRE_BUNDLE);
+        marker.setAttribute("element", req.getSymbolicName());
+        marker.setAttribute("versionRange", req.getVersions().toString());
+        marker.setAttribute(IMarker.MESSAGE, "Cannot resolve required bundle \""
+            + req.getSymbolicName() + "\" with version range " + req.getVersions());
+        marker.setAttribute(IMarker.SEVERITY, req.isOptional() ? IMarker.SEVERITY_WARNING
+            : IMarker.SEVERITY_ERROR);
+        marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
+    }
 
     /**
      * Returns the project custom preference pool.
@@ -317,9 +337,9 @@
      */
     public Preferences getPreferences()
     {
-        synchronized ( this )
+        synchronized (this)
         {
-            if ( preferences == null )
+            if (preferences == null)
             {
                 preferences = loadPreferences();
             }
@@ -328,83 +348,80 @@
         }
     }
 
-
     /**
      * @return
      */
     private synchronized IEclipsePreferences loadPreferences()
     {
-        IScopeContext context = new ProjectScope( getProject() );
-        final IEclipsePreferences eclipsePreferences = context.getNode( SigilCore.PLUGIN_ID );
+        IScopeContext context = new ProjectScope(getProject());
+        final IEclipsePreferences eclipsePreferences = context.getNode(SigilCore.PLUGIN_ID);
 
         // Listen to node removal from parent in order to reset cache
         INodeChangeListener nodeListener = new IEclipsePreferences.INodeChangeListener()
         {
-            public void added( IEclipsePreferences.NodeChangeEvent event )
+            public void added(IEclipsePreferences.NodeChangeEvent event)
             {
                 // do nothing
             }
 
-
-            public void removed( IEclipsePreferences.NodeChangeEvent event )
+            public void removed(IEclipsePreferences.NodeChangeEvent event)
             {
-                if ( event.getChild() == eclipsePreferences )
+                if (event.getChild() == eclipsePreferences)
                 {
-                    synchronized ( SigilProject.this )
+                    synchronized (SigilProject.this)
                     {
                         preferences = null;
                     }
-                    ( ( IEclipsePreferences ) eclipsePreferences.parent() ).removeNodeChangeListener( this );
+                    ((IEclipsePreferences) eclipsePreferences.parent()).removeNodeChangeListener(this);
                 }
             }
         };
 
-        ( ( IEclipsePreferences ) eclipsePreferences.parent() ).addNodeChangeListener( nodeListener );
+        ((IEclipsePreferences) eclipsePreferences.parent()).addNodeChangeListener(nodeListener);
 
         return eclipsePreferences;
     }
 
-
-    public Collection<IClasspathEntry> findExternalClasspath( IProgressMonitor monitor ) throws CoreException
+    public Collection<IClasspathEntry> findExternalClasspath(IProgressMonitor monitor)
+        throws CoreException
     {
-        return JavaHelper.resolveClasspathEntrys( this, monitor );
+        return JavaHelper.resolveClasspathEntrys(this, monitor);
     }
 
     public Version getVersion()
     {
         ISigilBundle bundle = getBundle();
-        return bundle == null ? null : bundle.getBundleInfo() == null ? null : bundle.getBundleInfo().getVersion();
+        return bundle == null ? null : bundle.getBundleInfo() == null ? null
+            : bundle.getBundleInfo().getVersion();
     }
 
-
     public String getSymbolicName()
     {
         ISigilBundle bundle = getBundle();
-        return bundle == null ? null : bundle.getBundleInfo() == null ? null : bundle.getBundleInfo().getSymbolicName();
+        return bundle == null ? null : bundle.getBundleInfo() == null ? null
+            : bundle.getBundleInfo().getSymbolicName();
     }
 
-
     public IProject getProject()
     {
         return project;
     }
 
-
     public ISigilBundle getBundle()
     {
         ISigilBundle b = null;
-        
+
         try
         {
             boolean newProject = false;
-            
-            synchronized ( bldProjectFile )
+
+            synchronized (bldProjectFile)
             {
-                if ( bundle == null )
+                if (bundle == null)
                 {
-                    if ( bldProjectFile.getLocation().toFile().exists() )
+                    if (bldProjectFile.getLocation().toFile().exists())
                     {
-                        bundle = parseContents( bldProjectFile );
+                        bundle = parseContents(bldProjectFile);
                     }
                     else
                     {
@@ -416,168 +433,165 @@
                 b = bundle;
             }
 
-            if ( newProject ) {
+            if (newProject)
+            {
                 NullProgressMonitor npm = new NullProgressMonitor();
-                bldProjectFile.create( buildContents(), true /* force */, npm );
-                project.refreshLocal( IResource.DEPTH_ONE, npm );
+                bldProjectFile.create(buildContents(), true /* force */, npm);
+                project.refreshLocal(IResource.DEPTH_ONE, npm);
             }
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to build bundle", e );
+            SigilCore.error("Failed to build bundle", e);
         }
-        
+
         return b;
     }
 
-
-    public void setBundle( ISigilBundle bundle )
+    public void setBundle(ISigilBundle bundle)
     {
-        synchronized( bldProjectFile ) {
+        synchronized (bldProjectFile)
+        {
             this.bundle = bundle;
         }
     }
 
-
     public IJavaProject getJavaModel()
     {
-        return JavaCore.create( project );
+        return JavaCore.create(project);
     }
 
-
     @Override
-    public boolean equals( Object obj )
+    public boolean equals(Object obj)
     {
-        if ( obj == null )
+        if (obj == null)
             return false;
 
-        if ( obj == this )
+        if (obj == this)
             return true;
 
         try
         {
-            SigilProject p = ( SigilProject ) obj;
-            return getSymbolicName().equals( p.getSymbolicName() )
-                && ( getVersion() == null ? p.getVersion() == null : getVersion().equals( p.getVersion() ) );
+            SigilProject p = (SigilProject) obj;
+            return getSymbolicName().equals(p.getSymbolicName())
+                && (getVersion() == null ? p.getVersion() == null : getVersion().equals(
+                    p.getVersion()));
         }
-        catch ( ClassCastException e )
+        catch (ClassCastException e)
         {
             return false;
         }
     }
 
-
     @Override
     public int hashCode()
     {
         int hc = getSymbolicName().hashCode();
-        if ( getVersion() != null ) {
+        if (getVersion() != null)
+        {
             hc *= getVersion().hashCode();
         }
         hc *= 7;
         return hc;
     }
 
-
     @Override
     public String toString()
     {
         return "SigilProject[" + getSymbolicName() + ":" + getVersion() + "]";
     }
 
-
-    public void resetClasspath( IProgressMonitor monitor ) throws CoreException
+    public void resetClasspath(IProgressMonitor monitor) throws CoreException
     {
-        Path containerPath = new Path( SigilCore.CLASSPATH_CONTAINER_PATH );
+        Path containerPath = new Path(SigilCore.CLASSPATH_CONTAINER_PATH);
         IJavaProject java = getJavaModel();
-        ClasspathContainerInitializer init = JavaCore
-            .getClasspathContainerInitializer( SigilCore.CLASSPATH_CONTAINER_PATH );
-        ThreadProgressMonitor.setProgressMonitor( monitor );
+        ClasspathContainerInitializer init = JavaCore.getClasspathContainerInitializer(SigilCore.CLASSPATH_CONTAINER_PATH);
+        ThreadProgressMonitor.setProgressMonitor(monitor);
         try
         {
-            init.requestClasspathContainerUpdate( containerPath, java, null );
+            init.requestClasspathContainerUpdate(containerPath, java, null);
         }
         finally
         {
-            ThreadProgressMonitor.setProgressMonitor( null );
+            ThreadProgressMonitor.setProgressMonitor(null);
         }
     }
 
-
     public IPath findBundleLocation() throws CoreException
     {
         IPath p = PathUtil.newPathIfExists(getBundle().getLocation());
-        if ( p == null )
+        if (p == null)
         {
-            p = SigilCore.getDefault().findDefaultBundleLocation( this );
+            p = SigilCore.getDefault().findDefaultBundleLocation(this);
         }
         return p;
     }
 
-
-    public IModelElement findImport( final String packageName, final IProgressMonitor monitor )
+    public IModelElement findImport(final String packageName,
+        final IProgressMonitor monitor)
     {
         final IModelElement[] found = new IModelElement[1];
 
-        visit( new IModelWalker()
+        visit(new IModelWalker()
         {
-            public boolean visit( IModelElement element )
+            public boolean visit(IModelElement element)
             {
-                if ( element instanceof IPackageImport )
+                if (element instanceof IPackageImport)
                 {
-                    IPackageImport pi = ( IPackageImport ) element;
-                    if ( pi.getPackageName().equals( packageName ) )
+                    IPackageImport pi = (IPackageImport) element;
+                    if (pi.getPackageName().equals(packageName))
                     {
                         found[0] = pi;
                         return false;
                     }
                 }
-                else if ( element instanceof IRequiredBundle )
+                else if (element instanceof IRequiredBundle)
                 {
-                    IRequiredBundle rb = ( IRequiredBundle ) element;
+                    IRequiredBundle rb = (IRequiredBundle) element;
                     try
                     {
-                        IRepositoryManager manager = SigilCore.getRepositoryManager( SigilProject.this );
-                        ResolutionConfig config = new ResolutionConfig( ResolutionConfig.IGNORE_ERRORS );
-                        IResolution res = manager.getBundleResolver().resolve( rb, config,
-                            new ResolutionMonitorAdapter( monitor ) );
-                        ISigilBundle b = res.getProvider( rb );
-                        for ( IPackageExport pe : b.getBundleInfo().getExports() )
+                        IRepositoryManager manager = SigilCore.getRepositoryManager(SigilProject.this);
+                        ResolutionConfig config = new ResolutionConfig(
+                            ResolutionConfig.IGNORE_ERRORS);
+                        IResolution res = manager.getBundleResolver().resolve(rb, config,
+                            new ResolutionMonitorAdapter(monitor));
+                        ISigilBundle b = res.getProvider(rb);
+                        for (IPackageExport pe : b.getBundleInfo().getExports())
                         {
-                            if ( pe.getPackageName().equals( packageName ) )
+                            if (pe.getPackageName().equals(packageName))
                             {
                                 found[0] = rb;
                                 return false;
                             }
                         }
                     }
-                    catch ( ResolutionException e )
+                    catch (ResolutionException e)
                     {
-                        SigilCore.error( "Failed to resolve " + rb, e );
+                        SigilCore.error("Failed to resolve " + rb, e);
                     }
                 }
                 return true;
             }
 
-        } );
+        });
 
         return found[0];
     }
 
-
-    public boolean isInClasspath( String packageName, IProgressMonitor monitor ) throws CoreException
+    public boolean isInClasspath(String packageName, IProgressMonitor monitor)
+        throws CoreException
     {
-        if ( findImport( packageName, monitor ) != null )
+        if (findImport(packageName, monitor) != null)
         {
             return true;
         }
 
-        for ( String path : getBundle().getClasspathEntrys() )
+        for (String path : getBundle().getClasspathEntrys())
         {
-            IClasspathEntry cp = getJavaModel().decodeClasspathEntry( path );
-            for ( IPackageFragmentRoot root : getJavaModel().findPackageFragmentRoots( cp ) )
+            IClasspathEntry cp = getJavaModel().decodeClasspathEntry(path);
+            for (IPackageFragmentRoot root : getJavaModel().findPackageFragmentRoots(cp))
             {
-                if ( findPackage( packageName, root ) )
+                if (findPackage(packageName, root))
                 {
                     return true;
                 }
@@ -586,38 +600,37 @@
         return false;
     }
 
-
-    public boolean isInClasspath( ISigilBundle bundle )
+    public boolean isInClasspath(ISigilBundle bundle)
     {
-        for ( String path : getBundle().getClasspathEntrys() )
+        for (String path : getBundle().getClasspathEntrys())
         {
-            IClasspathEntry cp = getJavaModel().decodeClasspathEntry( path );
-            switch ( cp.getEntryKind() )
+            IClasspathEntry cp = getJavaModel().decodeClasspathEntry(path);
+            switch (cp.getEntryKind())
             {
                 case IClasspathEntry.CPE_PROJECT:
-                    ISigilProjectModel p = bundle.getAncestor( ISigilProjectModel.class );
-                    return p != null && cp.getPath().equals( p.getProject().getFullPath() );
+                    ISigilProjectModel p = bundle.getAncestor(ISigilProjectModel.class);
+                    return p != null && cp.getPath().equals(p.getProject().getFullPath());
                 case IClasspathEntry.CPE_LIBRARY:
-                    return cp.getPath().equals( bundle.getLocation() );
+                    return cp.getPath().equals(bundle.getLocation());
             }
         }
 
         return false;
     }
 
-
-    private boolean findPackage( String packageName, IParent parent ) throws JavaModelException
+    private boolean findPackage(String packageName, IParent parent)
+        throws JavaModelException
     {
-        for ( IJavaElement e : parent.getChildren() )
+        for (IJavaElement e : parent.getChildren())
         {
-            if ( e.getElementType() == IJavaElement.PACKAGE_FRAGMENT )
+            if (e.getElementType() == IJavaElement.PACKAGE_FRAGMENT)
             {
-                return e.getElementName().equals( packageName );
+                return e.getElementName().equals(packageName);
             }
 
-            if ( e instanceof IParent )
+            if (e instanceof IParent)
             {
-                if ( findPackage( packageName, ( IParent ) e ) )
+                if (findPackage(packageName, (IParent) e))
                 {
                     return true;
                 }
@@ -627,113 +640,115 @@
         return false;
     }
 
-
     private ISigilBundle setupDefaults()
     {
-        ISigilBundle bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
-        IBundleModelElement info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
-        info.setSymbolicName( project.getName() );
-        bundle.setBundleInfo( info );
-        bundle.setParent( this );
+        ISigilBundle bundle = ModelElementFactory.getInstance().newModelElement(
+            ISigilBundle.class);
+        IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(
+            IBundleModelElement.class);
+        info.setSymbolicName(project.getName());
+        bundle.setBundleInfo(info);
+        bundle.setParent(this);
         return bundle;
     }
 
-
-    private ISigilBundle parseContents( IFile projectFile ) throws CoreException
+    private ISigilBundle parseContents(IFile projectFile) throws CoreException
     {
-        if ( projectFile.getName().equals( SigilCore.SIGIL_PROJECT_FILE ) )
+        if (projectFile.getName().equals(SigilCore.SIGIL_PROJECT_FILE))
         {
-            return parseBldContents( projectFile.getLocationURI() );
+            return parseBldContents(projectFile.getLocationURI());
         }
         else
         {
-            throw SigilCore.newCoreException( "Unexpected project file: " + projectFile.getName(), null );
+            throw SigilCore.newCoreException("Unexpected project file: "
+                + projectFile.getName(), null);
         }
     }
 
-
-    private ISigilBundle parseBldContents( URI uri ) throws CoreException
+    private ISigilBundle parseBldContents(URI uri) throws CoreException
     {
         try
         {
-            bldProject = BldFactory.getProject( uri, true );
+            bldProject = BldFactory.getProject(uri, true);
             ISigilBundle bundle = bldProject.getDefaultBundle();
-            
-            if ( bundle == null ) {
+
+            if (bundle == null)
+            {
                 throw SigilCore.newCoreException("No default bundle", null);
             }
-            
-            bundle.setParent( this );
+
+            bundle.setParent(this);
             return bundle;
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
-            throw SigilCore.newCoreException( "Failed to parse " + uri, e );
+            throw SigilCore.newCoreException("Failed to parse " + uri, e);
         }
     }
 
-
     private InputStream buildContents() throws CoreException
     {
         ByteArrayOutputStream buf = new ByteArrayOutputStream();
         try
         {
-            if ( bldProject == null )
+            if (bldProject == null)
             {
-                bldProject = BldFactory.newProject( bldProjectFile.getLocationURI(), null );
+                bldProject = BldFactory.newProject(bldProjectFile.getLocationURI(), null);
             }
-            bldProject.setDefaultBundle( getBundle() );
-            bldProject.saveTo( buf );
+            bldProject.setDefaultBundle(getBundle());
+            bldProject.saveTo(buf);
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
-            throw SigilCore.newCoreException( "Failed to save project file", e );
+            throw SigilCore.newCoreException("Failed to save project file", e);
         }
-        return new ByteArrayInputStream( buf.toByteArray() );
+        return new ByteArrayInputStream(buf.toByteArray());
     }
 
-
     public String getName()
     {
         return getProject().getName();
     }
 
-
     public IPath findOutputLocation() throws CoreException
     {
-        return getProject().getLocation().append( getJavaModel().getOutputLocation().removeFirstSegments( 1 ) );
+        return getProject().getLocation().append(
+            getJavaModel().getOutputLocation().removeFirstSegments(1));
     }
 
-
     public IBldProject getBldProject() throws CoreException
     {
         try
         {
-            return BldFactory.getProject( project.getFile( IBldProject.PROJECT_FILE ).getLocationURI() );
+            return BldFactory.getProject(project.getFile(IBldProject.PROJECT_FILE).getLocationURI());
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
-            throw SigilCore.newCoreException( "Failed to get project file: ", e );
+            throw SigilCore.newCoreException("Failed to get project file: ", e);
         }
     }
 
-
-    public boolean isInBundleClasspath( IPackageFragment root ) throws JavaModelException
+    public boolean isInBundleClasspath(IPackageFragment root) throws JavaModelException
     {
-        if ( getBundle().getClasspathEntrys().isEmpty() ) {
-            for ( String p : getBundle().getPackages() ) {
-                SigilCore.log("Checking " + p + "->" + root.getElementName() );
+        if (getBundle().getClasspathEntrys().isEmpty())
+        {
+            for (String p : getBundle().getPackages())
+            {
+                SigilCore.log("Checking " + p + "->" + root.getElementName());
                 Matcher m = GlobCompiler.compile(p).matcher(root.getElementName());
-                if ( m.matches() ) {
+                if (m.matches())
+                {
                     return true;
                 }
             }
             return false;
         }
-        else {
+        else
+        {
             IPackageFragmentRoot parent = (IPackageFragmentRoot) root.getParent();
-            String enc = getJavaModel().encodeClasspathEntry( parent.getRawClasspathEntry() );
-            return getBundle().getClasspathEntrys().contains( enc.trim() );
+            String enc = getJavaModel().encodeClasspathEntry(
+                parent.getRawClasspathEntry());
+            return getBundle().getClasspathEntrys().contains(enc.trim());
         }
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryConfiguration.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryConfiguration.java
index 5fdc320..081dc5a 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryConfiguration.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryConfiguration.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.model.repository;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
@@ -49,7 +48,6 @@
 import org.eclipse.swt.graphics.Image;
 import org.osgi.framework.Bundle;
 
-
 public class RepositoryConfiguration implements IRepositoryConfiguration
 {
 
@@ -64,33 +62,32 @@
 
     public static final String REPOSITORY_DEFAULT_SET = REPOSITORY + "default.set";
 
-
     public List<IRepositoryModel> loadRepositories()
     {
         IPreferenceStore prefs = SigilCore.getDefault().getPreferenceStore();
 
         ArrayList<IRepositoryModel> repositories = new ArrayList<IRepositoryModel>();
 
-        for ( RepositoryType type : loadRepositoryTypes() )
+        for (RepositoryType type : loadRepositoryTypes())
         {
             String typeID = type.getId();
 
-            if ( type.isDynamic() )
+            if (type.isDynamic())
             {
-                String instances = prefs.getString( REPOSITORY + typeID + INSTANCES );
-                if ( instances.trim().length() > 0 )
+                String instances = prefs.getString(REPOSITORY + typeID + INSTANCES);
+                if (instances.trim().length() > 0)
                 {
-                    for ( String instance : instances.split( "," ) )
+                    for (String instance : instances.split(","))
                     {
                         String key = REPOSITORY + typeID + "." + instance;
-                        repositories.add( loadRepository( instance, key, type, prefs ) );
+                        repositories.add(loadRepository(instance, key, type, prefs));
                     }
                 }
             }
             else
             {
                 String key = REPOSITORY + typeID;
-                repositories.add( loadRepository( typeID, key, type, prefs ) );
+                repositories.add(loadRepository(typeID, key, type, prefs));
             }
 
         }
@@ -98,12 +95,11 @@
         return repositories;
     }
 
-
-    public IRepositoryModel findRepository( String id )
+    public IRepositoryModel findRepository(String id)
     {
-        for ( IRepositoryModel model : loadRepositories() )
+        for (IRepositoryModel model : loadRepositories())
         {
-            if ( model.getId().equals( id ) )
+            if (model.getId().equals(id))
             {
                 return model;
             }
@@ -111,92 +107,93 @@
         return null;
     }
 
-
-    public void saveRepositories( List<IRepositoryModel> repositories ) throws CoreException
+    public void saveRepositories(List<IRepositoryModel> repositories)
+        throws CoreException
     {
         IPreferenceStore prefs = getPreferences();
 
         HashMap<IRepositoryType, List<IRepositoryModel>> mapped = new HashMap<IRepositoryType, List<IRepositoryModel>>(
-            repositories.size() );
+            repositories.size());
 
-        saveRepositoryPreferences( repositories, mapped );
-        createNewEntries( mapped, prefs );
-        deleteOldEntries( repositories, prefs );
+        saveRepositoryPreferences(repositories, mapped);
+        createNewEntries(mapped, prefs);
+        deleteOldEntries(repositories, prefs);
         // time stamp is used as a signal to the manager
         // to update its view of the stored repositories
-        timeStamp( prefs );
+        timeStamp(prefs);
     }
 
-
     public List<RepositoryType> loadRepositoryTypes()
     {
         List<RepositoryType> repositories = new ArrayList<RepositoryType>();
 
         IExtensionRegistry registry = Platform.getExtensionRegistry();
 
-        IExtensionPoint p = registry.getExtensionPoint( SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID );
+        IExtensionPoint p = registry.getExtensionPoint(SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID);
 
-        for ( IExtension e : p.getExtensions() )
+        for (IExtension e : p.getExtensions())
         {
-            for ( IConfigurationElement c : e.getConfigurationElements() )
+            for (IConfigurationElement c : e.getConfigurationElements())
             {
-                String id = c.getAttribute( "id" );
-                String type = c.getAttribute( "type" );
-                boolean dynamic = Boolean.valueOf( c.getAttribute( "dynamic" ) );
-                String icon = c.getAttribute( "icon" );
-                Image image = ( icon == null || icon.trim().length() == 0 ) ? null : loadImage( e, icon );
-                repositories.add( new RepositoryType( id, type, dynamic, image ) );
+                String id = c.getAttribute("id");
+                String type = c.getAttribute("type");
+                boolean dynamic = Boolean.valueOf(c.getAttribute("dynamic"));
+                String icon = c.getAttribute("icon");
+                Image image = (icon == null || icon.trim().length() == 0) ? null
+                    : loadImage(e, icon);
+                repositories.add(new RepositoryType(id, type, dynamic, image));
             }
         }
 
         return repositories;
     }
 
-
-    public IRepositoryModel newRepositoryElement( IRepositoryType type )
+    public IRepositoryModel newRepositoryElement(IRepositoryType type)
     {
         String id = UUID.randomUUID().toString();
         PreferenceStore prefs = new PreferenceStore();
-        RepositoryModel element = new RepositoryModel( id, "", type, prefs );
-        prefs.setFilename( makeFileName( element ) );
-        prefs.setValue( "id", id );
+        RepositoryModel element = new RepositoryModel(id, "", type, prefs);
+        prefs.setFilename(makeFileName(element));
+        prefs.setValue("id", id);
         return element;
     }
 
-
     public IRepositorySet getDefaultRepositorySet()
     {
         //int level = findLevel( key + LEVEL, type, prefs );
         ArrayList<IRepositoryModel> reps = new ArrayList<IRepositoryModel>();
-        for ( String s : PrefsUtils.stringToArray( getPreferences().getString( REPOSITORY_DEFAULT_SET ) ) )
-        {   
-            IRepositoryModel rep = findRepository( s );
-            if ( rep == null ) {
-                SigilCore.error( "Missing repository for " + s );
+        for (String s : PrefsUtils.stringToArray(getPreferences().getString(
+            REPOSITORY_DEFAULT_SET)))
+        {
+            IRepositoryModel rep = findRepository(s);
+            if (rep == null)
+            {
+                SigilCore.error("Missing repository for " + s);
             }
-            else {
-                reps.add( rep );
+            else
+            {
+                reps.add(rep);
             }
         }
-        return new RepositorySet( reps );
+        return new RepositorySet(reps);
     }
 
-
-    public IRepositorySet getRepositorySet( String name )
+    public IRepositorySet getRepositorySet(String name)
     {
         String key = REPOSITORY_SET + name;
-        if ( getPreferences().contains( key ) )
+        if (getPreferences().contains(key))
         {
             ArrayList<IRepositoryModel> reps = new ArrayList<IRepositoryModel>();
-            for ( String s : PrefsUtils.stringToArray( getPreferences().getString( key ) ) )
+            for (String s : PrefsUtils.stringToArray(getPreferences().getString(key)))
             {
-                IRepositoryModel rep = findRepository( s );
-                if ( rep == null ) {
-                    throw new IllegalStateException( "Missing repository for " + s );
+                IRepositoryModel rep = findRepository(s);
+                if (rep == null)
+                {
+                    throw new IllegalStateException("Missing repository for " + s);
                 }
-                reps.add( rep );
+                reps.add(rep);
             }
-            return new RepositorySet( reps );
+            return new RepositorySet(reps);
         }
         else
         {
@@ -204,282 +201,270 @@
         }
     }
 
-
     public Map<String, IRepositorySet> loadRepositorySets()
     {
         IPreferenceStore store = getPreferences();
 
         HashMap<String, IRepositorySet> sets = new HashMap<String, IRepositorySet>();
 
-        for ( String name : PrefsUtils.stringToArray( store.getString( REPOSITORY_SETS ) ) )
+        for (String name : PrefsUtils.stringToArray(store.getString(REPOSITORY_SETS)))
         {
             String key = REPOSITORY_SET + name;
             ArrayList<IRepositoryModel> reps = new ArrayList<IRepositoryModel>();
-            for ( String s : PrefsUtils.stringToArray( getPreferences().getString( key ) ) )
+            for (String s : PrefsUtils.stringToArray(getPreferences().getString(key)))
             {
-                reps.add( findRepository( s ) );
+                reps.add(findRepository(s));
             }
-            sets.put( name, new RepositorySet( reps ) );
+            sets.put(name, new RepositorySet(reps));
         }
 
         return sets;
     }
 
-
-    public void saveRepositorySets( Map<String, IRepositorySet> sets )
+    public void saveRepositorySets(Map<String, IRepositorySet> sets)
     {
         IPreferenceStore store = getPreferences();
 
         ArrayList<String> names = new ArrayList<String>();
 
-        for ( Map.Entry<String, IRepositorySet> set : sets.entrySet() )
+        for (Map.Entry<String, IRepositorySet> set : sets.entrySet())
         {
             String name = set.getKey();
             String key = REPOSITORY_SET + name;
             ArrayList<String> ids = new ArrayList<String>();
-            for ( IRepositoryModel m : set.getValue().getRepositories() )
+            for (IRepositoryModel m : set.getValue().getRepositories())
             {
-                ids.add( m.getId() );
+                ids.add(m.getId());
             }
-            store.setValue( key, PrefsUtils.listToString( ids ) );
-            names.add( name );
+            store.setValue(key, PrefsUtils.listToString(ids));
+            names.add(name);
         }
 
-        for ( String name : PrefsUtils.stringToArray( store.getString( REPOSITORY_SETS ) ) )
+        for (String name : PrefsUtils.stringToArray(store.getString(REPOSITORY_SETS)))
         {
-            if ( !names.contains( name ) )
+            if (!names.contains(name))
             {
                 String key = REPOSITORY_SET + name;
-                store.setToDefault( key );
+                store.setToDefault(key);
             }
         }
 
-        store.setValue( REPOSITORY_SETS, PrefsUtils.listToString( names ) );
-        timeStamp( store );
+        store.setValue(REPOSITORY_SETS, PrefsUtils.listToString(names));
+        timeStamp(store);
     }
 
-
-    public void setDefaultRepositorySet( IRepositorySet defaultSet )
+    public void setDefaultRepositorySet(IRepositorySet defaultSet)
     {
         ArrayList<String> ids = new ArrayList<String>();
-        for ( IRepositoryModel m : defaultSet.getRepositories() )
+        for (IRepositoryModel m : defaultSet.getRepositories())
         {
-            ids.add( m.getId() );
+            ids.add(m.getId());
         }
         IPreferenceStore prefs = getPreferences();
-        prefs.setValue( REPOSITORY_DEFAULT_SET, PrefsUtils.listToString( ids ) );
-        timeStamp( prefs );
+        prefs.setValue(REPOSITORY_DEFAULT_SET, PrefsUtils.listToString(ids));
+        timeStamp(prefs);
     }
 
-
-    private void timeStamp( IPreferenceStore prefs )
+    private void timeStamp(IPreferenceStore prefs)
     {
-        prefs.setValue( REPOSITORY_TIMESTAMP, System.currentTimeMillis() );
+        prefs.setValue(REPOSITORY_TIMESTAMP, System.currentTimeMillis());
     }
 
-
     private IPreferenceStore getPreferences()
     {
         return SigilCore.getDefault().getPreferenceStore();
     }
 
-
-    private void deleteOldEntries( List<IRepositoryModel> repositories, IPreferenceStore prefs )
+    private void deleteOldEntries(List<IRepositoryModel> repositories,
+        IPreferenceStore prefs)
     {
-        for ( IRepositoryModel e : loadRepositories() )
+        for (IRepositoryModel e : loadRepositories())
         {
-            if ( !repositories.contains( e ) )
+            if (!repositories.contains(e))
             {
-                new File( makeFileName( e ) ).delete();
-                String key = makeKey( e );
-                prefs.setToDefault( key + LOC );
-                prefs.setToDefault( key + NAME );
+                new File(makeFileName(e)).delete();
+                String key = makeKey(e);
+                prefs.setToDefault(key + LOC);
+                prefs.setToDefault(key + NAME);
             }
         }
 
-        for ( IRepositoryType type : loadRepositoryTypes() )
+        for (IRepositoryType type : loadRepositoryTypes())
         {
             boolean found = false;
-            for ( IRepositoryModel e : repositories )
+            for (IRepositoryModel e : repositories)
             {
-                if ( e.getType().equals( type ) )
+                if (e.getType().equals(type))
                 {
                     found = true;
                     break;
                 }
             }
 
-            if ( !found )
+            if (!found)
             {
-                prefs.setToDefault( REPOSITORY + type.getId() + INSTANCES );
+                prefs.setToDefault(REPOSITORY + type.getId() + INSTANCES);
             }
         }
     }
 
-
-    private static void createNewEntries( HashMap<IRepositoryType, List<IRepositoryModel>> mapped,
-        IPreferenceStore prefs )
+    private static void createNewEntries(
+        HashMap<IRepositoryType, List<IRepositoryModel>> mapped, IPreferenceStore prefs)
     {
-        for ( Map.Entry<IRepositoryType, List<IRepositoryModel>> entry : mapped.entrySet() )
+        for (Map.Entry<IRepositoryType, List<IRepositoryModel>> entry : mapped.entrySet())
         {
             IRepositoryType type = entry.getKey();
-            if ( type.isDynamic() )
+            if (type.isDynamic())
             {
                 StringBuffer buf = new StringBuffer();
 
-                for ( IRepositoryModel element : entry.getValue() )
+                for (IRepositoryModel element : entry.getValue())
                 {
-                    if ( buf.length() > 0 )
+                    if (buf.length() > 0)
                     {
-                        buf.append( "," );
+                        buf.append(",");
                     }
-                    buf.append( element.getId() );
-                    saveRepository( element, prefs );
+                    buf.append(element.getId());
+                    saveRepository(element, prefs);
                 }
 
-                prefs.setValue( REPOSITORY + type.getId() + INSTANCES, buf.toString() );
+                prefs.setValue(REPOSITORY + type.getId() + INSTANCES, buf.toString());
             }
             else
             {
-                IRepositoryModel element = entry.getValue().get( 0 );
-                saveRepository( element, prefs );
+                IRepositoryModel element = entry.getValue().get(0);
+                saveRepository(element, prefs);
             }
         }
     }
 
-
-    private static void saveRepositoryPreferences( List<IRepositoryModel> repositories,
-        HashMap<IRepositoryType, List<IRepositoryModel>> mapped ) throws CoreException
+    private static void saveRepositoryPreferences(List<IRepositoryModel> repositories,
+        HashMap<IRepositoryType, List<IRepositoryModel>> mapped) throws CoreException
     {
-        for ( IRepositoryModel rep : repositories )
+        for (IRepositoryModel rep : repositories)
         {
             try
             {
-                createDir( makeFileName( rep ) );
+                createDir(makeFileName(rep));
                 rep.getPreferences().save();
-                List<IRepositoryModel> list = mapped.get( rep.getType() );
-                if ( list == null )
+                List<IRepositoryModel> list = mapped.get(rep.getType());
+                if (list == null)
                 {
-                    list = new ArrayList<IRepositoryModel>( 1 );
-                    mapped.put( rep.getType(), list );
+                    list = new ArrayList<IRepositoryModel>(1);
+                    mapped.put(rep.getType(), list);
                 }
-                list.add( rep );
+                list.add(rep);
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                throw SigilCore.newCoreException( "Failed to save repository preferences", e );
+                throw SigilCore.newCoreException("Failed to save repository preferences",
+                    e);
             }
         }
     }
 
-
-    private static void createDir( String fileName )
+    private static void createDir(String fileName)
     {
-        File file = new File( fileName );
+        File file = new File(fileName);
         file.getParentFile().mkdirs();
     }
 
-
-    private static void saveRepository( IRepositoryModel element, IPreferenceStore prefs )
+    private static void saveRepository(IRepositoryModel element, IPreferenceStore prefs)
     {
-        String key = makeKey( element );
-        prefs.setValue( key + LOC, makeFileName( element ) );
-        if ( element.getType().isDynamic() )
+        String key = makeKey(element);
+        prefs.setValue(key + LOC, makeFileName(element));
+        if (element.getType().isDynamic())
         {
-            prefs.setValue( key + NAME, element.getName() );
+            prefs.setValue(key + NAME, element.getName());
         }
-        prefs.setValue( key + TIMESTAMP, now() );
+        prefs.setValue(key + TIMESTAMP, now());
     }
 
-
     private static long now()
     {
         return System.currentTimeMillis();
     }
 
-
-    private static String makeKey( IRepositoryModel element )
+    private static String makeKey(IRepositoryModel element)
     {
         IRepositoryType type = element.getType();
 
         String key = REPOSITORY + type.getId();
-        if ( type.isDynamic() )
+        if (type.isDynamic())
             key = key + "." + element.getId();
 
         return key;
     }
 
-
-    private static String makeFileName( IRepositoryModel element )
+    private static String makeFileName(IRepositoryModel element)
     {
         IPath path = SigilCore.getDefault().getStateLocation();
-        path = path.append( "repository" );
-        path = path.append( element.getType().getId() );
-        path = path.append( element.getId() );
+        path = path.append("repository");
+        path = path.append(element.getType().getId());
+        path = path.append(element.getId());
         return path.toOSString();
     }
 
-
-    private static RepositoryModel loadRepository( String id, String key, RepositoryType type, IPreferenceStore prefs )
+    private static RepositoryModel loadRepository(String id, String key,
+        RepositoryType type, IPreferenceStore prefs)
     {
-        String name = type.isDynamic() ? prefs.getString( key + NAME ) : type.getType();
+        String name = type.isDynamic() ? prefs.getString(key + NAME) : type.getType();
 
         PreferenceStore repPrefs = new PreferenceStore();
-        RepositoryModel element = new RepositoryModel( id, name, type, repPrefs );
+        RepositoryModel element = new RepositoryModel(id, name, type, repPrefs);
 
-        String loc = prefs.getString( key + LOC );
+        String loc = prefs.getString(key + LOC);
 
-        if ( loc == null || loc.trim().length() == 0 )
+        if (loc == null || loc.trim().length() == 0)
         {
-            loc = makeFileName( element );
+            loc = makeFileName(element);
         }
 
-        repPrefs.setFilename( loc );
+        repPrefs.setFilename(loc);
 
-        if ( new File( loc ).exists() )
+        if (new File(loc).exists())
         {
             try
             {
                 repPrefs.load();
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                SigilCore.error( "Failed to load properties for repository " + key, e );
+                SigilCore.error("Failed to load properties for repository " + key, e);
             }
         }
 
-        repPrefs.setValue( "id", id );
+        repPrefs.setValue("id", id);
 
         return element;
     }
 
-
     @SuppressWarnings("unchecked")
-    private static Image loadImage( IExtension ext, String icon )
+    private static Image loadImage(IExtension ext, String icon)
     {
-        int i = icon.lastIndexOf( "/" );
-        String path = i == -1 ? "/" : icon.substring( 0, i );
-        String name = i == -1 ? icon : icon.substring( i + 1 );
+        int i = icon.lastIndexOf("/");
+        String path = i == -1 ? "/" : icon.substring(0, i);
+        String name = i == -1 ? icon : icon.substring(i + 1);
 
-        Bundle b = Platform.getBundle( ext.getContributor().getName() );
+        Bundle b = Platform.getBundle(ext.getContributor().getName());
 
-        Enumeration<URL> en = b.findEntries( path, name, false );
+        Enumeration<URL> en = b.findEntries(path, name, false);
         Image image = null;
 
-        if ( en.hasMoreElements() )
+        if (en.hasMoreElements())
         {
             try
             {
-                image = SigilCore.loadImage( en.nextElement() );
+                image = SigilCore.loadImage(en.nextElement());
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                SigilCore.error( "Failed to load image", e );
+                SigilCore.error("Failed to load image", e);
             }
         }
         else
         {
-            SigilCore.error( "No such image " + icon + " in bundle " + b.getSymbolicName() );
+            SigilCore.error("No such image " + icon + " in bundle " + b.getSymbolicName());
         }
 
         return image;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryModel.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryModel.java
index bdc7a6d..2b52c45 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryModel.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryModel.java
@@ -19,12 +19,10 @@
 
 package org.apache.felix.sigil.eclipse.internal.model.repository;
 
-
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryType;
 import org.eclipse.jface.preference.PreferenceStore;
 
-
 public class RepositoryModel implements IRepositoryModel
 {
     private String id;
@@ -35,8 +33,7 @@
 
     private PreferenceStore preferences;
 
-
-    public RepositoryModel( String id, String name, IRepositoryType type, PreferenceStore preferences )
+    public RepositoryModel(String id, String name, IRepositoryType type, PreferenceStore preferences)
     {
         this.id = id;
         this.name = name;
@@ -44,59 +41,51 @@
         this.preferences = preferences;
     }
 
-
     public PreferenceStore getPreferences()
     {
         return preferences;
     }
 
-
     public IRepositoryType getType()
     {
         return type;
     }
 
-
     public String getId()
     {
         return id;
     }
 
-
     public String getName()
     {
         return name;
     }
 
-
-    public void setName( String name )
+    public void setName(String name)
     {
         this.name = name;
     }
 
-
     @Override
-    public boolean equals( Object obj )
+    public boolean equals(Object obj)
     {
         try
         {
-            RepositoryModel e = ( RepositoryModel ) obj;
-            return id.equals( e.id );
+            RepositoryModel e = (RepositoryModel) obj;
+            return id.equals(e.id);
         }
-        catch ( ClassCastException e )
+        catch (ClassCastException e)
         {
             return false;
         }
     }
 
-
     @Override
     public int hashCode()
     {
         return id.hashCode();
     }
 
-
     public String toString()
     {
         return type.getId() + ":" + id + ":" + name;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryType.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryType.java
index bb05fe0..d65c174 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryType.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryType.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.internal.model.repository;
 
-
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryType;
 import org.eclipse.swt.graphics.Image;
 
-
 public class RepositoryType implements IRepositoryType
 {
     private String type;
@@ -31,8 +29,7 @@
     private Image icon;
     private boolean dynamic;
 
-
-    public RepositoryType( String id, String type, boolean dynamic, Image icon )
+    public RepositoryType(String id, String type, boolean dynamic, Image icon)
     {
         this.id = id;
         this.type = type;
@@ -40,53 +37,46 @@
         this.icon = icon;
     }
 
-
     public String getType()
     {
         return type;
     }
 
-
     public String getId()
     {
         return id;
     }
 
-
     public Image getIcon()
     {
         return icon;
     }
 
-
     public boolean isDynamic()
     {
         return dynamic;
     }
 
-
     @Override
-    public boolean equals( Object obj )
+    public boolean equals(Object obj)
     {
         try
         {
-            RepositoryType t = ( RepositoryType ) obj;
-            return t.id.equals( id );
+            RepositoryType t = (RepositoryType) obj;
+            return t.id.equals(id);
         }
-        catch ( ClassCastException e )
+        catch (ClassCastException e)
         {
             return false;
         }
     }
 
-
     @Override
     public int hashCode()
     {
         return id.hashCode();
     }
 
-
     @Override
     public String toString()
     {
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/GlobalRepositoryManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/GlobalRepositoryManager.java
index ec03e8a..688c041 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/GlobalRepositoryManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/GlobalRepositoryManager.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
 
-
 import java.util.List;
 
 import org.apache.felix.sigil.common.repository.IRepositoryManager;
@@ -27,21 +26,19 @@
 import org.apache.felix.sigil.eclipse.internal.repository.eclipse.SigilRepositoryManager;
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
 
-
 public class GlobalRepositoryManager extends SigilRepositoryManager implements IRepositoryManager
 {
 
     public GlobalRepositoryManager(RepositoryMap map)
     {
-        super( null, map );
+        super(null, map);
     }
 
-
     @Override
     protected IRepositoryModel[] findRepositories()
     {
         List<IRepositoryModel> repos = SigilCore.getRepositoryConfiguration().loadRepositories();
-        return repos.toArray( new IRepositoryModel[repos.size()] );
+        return repos.toArray(new IRepositoryModel[repos.size()]);
     }
 
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
index 9b8642f..c4f124c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -41,22 +40,19 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 
-
 public class OSGiInstallRepository extends AbstractBundleRepository
 {
 
     private Map<String, List<ISigilBundle>> bundles;
 
-
-    public OSGiInstallRepository( String id )
+    public OSGiInstallRepository(String id)
     {
-        super( id );
+        super(id);
     }
 
-
     public void refresh()
     {
-        synchronized ( this )
+        synchronized (this)
         {
             bundles = null;
         }
@@ -64,41 +60,40 @@
         notifyChange();
     }
 
-
     @Override
-    public void accept( IRepositoryVisitor visitor, int options )
+    public void accept(IRepositoryVisitor visitor, int options)
     {
         IOSGiInstall install = SigilCore.getInstallManager().getDefaultInstall();
 
-        if ( install != null )
+        if (install != null)
         {
             List<ISigilBundle> found = null;
 
-            synchronized ( this )
+            synchronized (this)
             {
-                found = bundles == null ? null : bundles.get( install.getId() );
+                found = bundles == null ? null : bundles.get(install.getId());
             }
 
-            if ( found == null )
+            if (found == null)
             {
                 found = new ArrayList<ISigilBundle>();
                 IPath source = install.getType().getSourceLocation();
 
-                for ( IPath p : install.getType().getDefaultBundleLocations() )
+                for (IPath p : install.getType().getDefaultBundleLocations())
                 {
-                    loadBundle( p, found, source );
+                    loadBundle(p, found, source);
                 }
 
-                synchronized ( this )
+                synchronized (this)
                 {
                     bundles = new HashMap<String, List<ISigilBundle>>();
-                    bundles.put( install.getId(), found );
+                    bundles.put(install.getId(), found);
                 }
             }
 
-            for ( ISigilBundle b : found )
+            for (ISigilBundle b : found)
             {
-                if ( !visitor.visit( b ) )
+                if (!visitor.visit(b))
                 {
                     break;
                 }
@@ -106,64 +101,62 @@
         }
     }
 
-
-    private void loadBundle( IPath p, List<ISigilBundle> bundles, IPath source )
+    private void loadBundle(IPath p, List<ISigilBundle> bundles, IPath source)
     {
         File f = p.toFile();
         JarFile jar = null;
         try
         {
-            jar = new JarFile( f );
-            ISigilBundle bundle = buildBundle( jar.getManifest(), f );
-            if ( bundle != null )
+            jar = new JarFile(f);
+            ISigilBundle bundle = buildBundle(jar.getManifest(), f);
+            if (bundle != null)
             {
-                bundle.setLocation( f );
-                bundle.setSourcePathLocation( source.toFile() );
+                bundle.setLocation(f);
+                bundle.setSourcePathLocation(source.toFile());
                 // XXX hard coded src location
-                bundle.setSourceRootPath( "src" );
-                bundles.add( bundle );
+                bundle.setSourceRootPath("src");
+                bundles.add(bundle);
             }
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
-            BldCore.error( "Failed to read jar file " + f, e );
+            BldCore.error("Failed to read jar file " + f, e);
         }
-        catch ( ModelElementFactoryException e )
+        catch (ModelElementFactoryException e)
         {
-            BldCore.error( "Failed to build bundle " + f, e );
+            BldCore.error("Failed to build bundle " + f, e);
         }
-        catch ( RuntimeException e )
+        catch (RuntimeException e)
         {
-            BldCore.error( "Failed to build bundle " + f, e );
+            BldCore.error("Failed to build bundle " + f, e);
         }
         finally
         {
-            if ( jar != null )
+            if (jar != null)
             {
                 try
                 {
                     jar.close();
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
-                    BldCore.error( "Failed to close jar file", e );
+                    BldCore.error("Failed to close jar file", e);
                 }
             }
         }
     }
 
-
-    private ISigilBundle buildBundle( Manifest manifest, File f )
+    private ISigilBundle buildBundle(Manifest manifest, File f)
     {
-        IBundleModelElement info = buildBundleModelElement( manifest );
+        IBundleModelElement info = buildBundleModelElement(manifest);
 
         ISigilBundle bundle = null;
 
-        if ( info != null )
+        if (info != null)
         {
-            bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
-            bundle.addChild( info );
-            bundle.setLocation( f );
+            bundle = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
+            bundle.addChild(info);
+            bundle.setLocation(f);
         }
 
         return bundle;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java
index ebbb2a1..77591e1 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java
@@ -19,17 +19,15 @@
 
 package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
 
-
 import java.util.Properties;
 
 import org.apache.felix.sigil.common.repository.IBundleRepository;
 import org.apache.felix.sigil.common.repository.IRepositoryProvider;
 
-
 public class OSGiInstallRepositoryProvider implements IRepositoryProvider
 {
-    public IBundleRepository createRepository( String id, Properties preferences )
+    public IBundleRepository createRepository(String id, Properties preferences)
     {
-        return new OSGiInstallRepository( id );
+        return new OSGiInstallRepository(id);
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/RepositoryMap.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/RepositoryMap.java
index 27ce7b5..3c736ec 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/RepositoryMap.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/RepositoryMap.java
@@ -33,21 +33,20 @@
         final Properties pref;
         final IBundleRepository repo;
 
-
-        RepositoryCache( Properties pref, IBundleRepository repo )
+        RepositoryCache(Properties pref, IBundleRepository repo)
         {
             this.pref = pref;
             this.repo = repo;
         }
     }
-    
+
     private HashMap<String, RepositoryCache> cachedRepositories = new HashMap<String, RepositoryCache>();
 
     synchronized void retainAll(Collection<String> ids)
     {
-        for ( Iterator<String> i = cachedRepositories.keySet().iterator(); i.hasNext(); )
+        for (Iterator<String> i = cachedRepositories.keySet().iterator(); i.hasNext();)
         {
-            if ( !ids.contains( i.next() ) )
+            if (!ids.contains(i.next()))
             {
                 i.remove();
             }
@@ -63,8 +62,7 @@
     synchronized void put(String id, RepositoryCache cache)
     {
         // TODO Auto-generated method stub
-        
-    }
 
+    }
 
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java
index 130e0a6..1edf9ef 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
 
-
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -47,40 +46,35 @@
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 
-
-public class SigilRepositoryManager extends AbstractRepositoryManager implements IRepositoryManager,
-    IPropertyChangeListener
+public class SigilRepositoryManager extends AbstractRepositoryManager implements IRepositoryManager, IPropertyChangeListener
 {
 
     private final String repositorySet;
 
     private RepositoryMap cachedRepositories;
 
-    public SigilRepositoryManager( String repositorySet, RepositoryMap cachedRepositories )
+    public SigilRepositoryManager(String repositorySet, RepositoryMap cachedRepositories)
     {
         this.repositorySet = repositorySet;
         this.cachedRepositories = cachedRepositories;
     }
 
-
     @Override
     public void initialise()
     {
         super.initialise();
-        SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener( this );
+        SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener(this);
     }
 
-
     public void destroy()
     {
         IPreferenceStore prefs = SigilCore.getDefault().getPreferenceStore();
-        if ( prefs != null )
+        if (prefs != null)
         {
-            prefs.removePropertyChangeListener( this );
+            prefs.removePropertyChangeListener(this);
         }
     }
 
-
     @Override
     protected void loadRepositories()
     {
@@ -90,54 +84,54 @@
         HashSet<String> ids = new HashSet<String>();
 
         IRepositoryModel[] models = findRepositories();
-        for ( IRepositoryModel repo : models )
+        for (IRepositoryModel repo : models)
         {
             try
             {
-                IRepositoryProvider provider = findProvider( repo.getType() );
+                IRepositoryProvider provider = findProvider(repo.getType());
                 String id = repo.getId();
                 IBundleRepository repoImpl = null;
-                if ( repo.getType().isDynamic() )
+                if (repo.getType().isDynamic())
                 {
                     String instance = "repository." + repo.getType().getId() + "." + id;
-                    String loc = prefs.getString( instance + ".loc" );
-                    Properties pref = loadPreferences( loc );
-                    repoImpl = loadRepository( id, pref, provider );
+                    String loc = prefs.getString(instance + ".loc");
+                    Properties pref = loadPreferences(loc);
+                    repoImpl = loadRepository(id, pref, provider);
                 }
                 else
                 {
-                    repoImpl = loadRepository( id, null, provider );
+                    repoImpl = loadRepository(id, null, provider);
                 }
 
-                repos.add( repoImpl );
-                ids.add( id );
+                repos.add(repoImpl);
+                ids.add(id);
             }
-            catch ( Exception e )
+            catch (Exception e)
             {
-                SigilCore.error( "Failed to load repository for " + repo, e );
+                SigilCore.error("Failed to load repository for " + repo, e);
             }
         }
 
-        setRepositories( repos.toArray( new IBundleRepository[repos.size()] ) );
+        setRepositories(repos.toArray(new IBundleRepository[repos.size()]));
 
-        cachedRepositories.retainAll( ids );
+        cachedRepositories.retainAll(ids);
     }
 
-
-    private IRepositoryProvider findProvider( IRepositoryType repositoryType ) throws CoreException
+    private IRepositoryProvider findProvider(IRepositoryType repositoryType)
+        throws CoreException
     {
         String id = repositoryType.getId();
 
         IExtensionRegistry registry = Platform.getExtensionRegistry();
-        IExtensionPoint p = registry.getExtensionPoint( SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID );
+        IExtensionPoint p = registry.getExtensionPoint(SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID);
 
-        for ( IExtension e : p.getExtensions() )
+        for (IExtension e : p.getExtensions())
         {
-            for ( IConfigurationElement c : e.getConfigurationElements() )
+            for (IConfigurationElement c : e.getConfigurationElements())
             {
-                if ( id.equals( c.getAttribute( "id" ) ) )
+                if (id.equals(c.getAttribute("id")))
                 {
-                    IRepositoryProvider provider = ( IRepositoryProvider ) c.createExecutableExtension( "class" );
+                    IRepositoryProvider provider = (IRepositoryProvider) c.createExecutableExtension("class");
                     return provider;
                 }
             }
@@ -146,84 +140,84 @@
         return null;
     }
 
-
     protected IRepositoryModel[] findRepositories()
     {
-        if ( repositorySet == null )
+        if (repositorySet == null)
         {
             return SigilCore.getRepositoryConfiguration().getDefaultRepositorySet().getRepositories();
         }
         else
         {
-            IRepositorySet set = SigilCore.getRepositoryConfiguration().getRepositorySet( repositorySet );
-            if ( set == null ) {
-                SigilCore.error( "Unknown repository set " + repositorySet );
+            IRepositorySet set = SigilCore.getRepositoryConfiguration().getRepositorySet(
+                repositorySet);
+            if (set == null)
+            {
+                SigilCore.error("Unknown repository set " + repositorySet);
                 return SigilCore.getRepositoryConfiguration().getDefaultRepositorySet().getRepositories();
             }
-            else {
+            else
+            {
                 return set.getRepositories();
             }
         }
     }
 
-
-    private IBundleRepository loadRepository( String id, Properties pref, IRepositoryProvider provider )
-        throws RepositoryException
+    private IBundleRepository loadRepository(String id, Properties pref,
+        IRepositoryProvider provider) throws RepositoryException
     {
         try
         {
-            if ( pref == null )
+            if (pref == null)
             {
                 pref = new Properties();
             }
 
-            RepositoryCache cache = cachedRepositories.get( id );
+            RepositoryCache cache = cachedRepositories.get(id);
 
-            if ( cache == null || !cache.pref.equals( pref ) )
+            if (cache == null || !cache.pref.equals(pref))
             {
-                IBundleRepository repo = provider.createRepository( id, pref );
-                cache = new RepositoryCache( pref, repo );
-                cachedRepositories.put( id, cache );
+                IBundleRepository repo = provider.createRepository(id, pref);
+                cache = new RepositoryCache(pref, repo);
+                cachedRepositories.put(id, cache);
             }
 
             return cache.repo;
         }
-        catch ( RuntimeException e )
+        catch (RuntimeException e)
         {
-            throw new RepositoryException( "Failed to build repositories", e );
+            throw new RepositoryException("Failed to build repositories", e);
         }
     }
 
-
-    private Properties loadPreferences( String loc ) throws FileNotFoundException, IOException
+    private Properties loadPreferences(String loc) throws FileNotFoundException,
+        IOException
     {
         FileInputStream in = null;
         try
         {
             Properties pref = new Properties();
-            pref.load( new FileInputStream( loc ) );
+            pref.load(new FileInputStream(loc));
             return pref;
         }
         finally
         {
-            if ( in != null )
+            if (in != null)
             {
                 try
                 {
                     in.close();
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
-                    SigilCore.error( "Failed to close file", e );
+                    SigilCore.error("Failed to close file", e);
                 }
             }
         }
     }
 
-
-    public void propertyChange( PropertyChangeEvent event )
+    public void propertyChange(PropertyChangeEvent event)
     {
-        if ( event.getProperty().equals( "repository.timestamp" ) )
+        if (event.getProperty().equals("repository.timestamp"))
         {
             loadRepositories();
         }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java
index 7bd02e8..19e1e82 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
 
-
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
@@ -49,91 +48,93 @@
 {
 
     private static final int UPDATE_MASK = IResourceDelta.CONTENT | IResourceDelta.OPEN;
-    
-    static final int EVENT_MASKS = IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_REFRESH;
 
-    public WorkspaceRepository( String id )
+    static final int EVENT_MASKS = IResourceChangeEvent.PRE_DELETE
+        | IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_REFRESH;
+
+    public WorkspaceRepository(String id)
     {
-        super( id );
-    }    
-      
-    
+        super(id);
+    }
+
     @Override
-    public void accept( IRepositoryVisitor visitor, int options )
+    public void accept(IRepositoryVisitor visitor, int options)
     {
         List<ISigilProjectModel> models = SigilCore.getRoot().getProjects();
-        for ( ISigilProjectModel project : models )
+        for (ISigilProjectModel project : models)
         {
             ISigilBundle b = project.getBundle();
-            if ( b == null )
+            if (b == null)
             {
-                SigilCore.error( "No bundle found for project " + project.getProject().getName() );
+                SigilCore.error("No bundle found for project "
+                    + project.getProject().getName());
             }
             else
             {
-                if ( (options & ResolutionConfig.COMPILE_TIME) != 0 ) {
+                if ((options & ResolutionConfig.COMPILE_TIME) != 0)
+                {
                     b = compileTimeFilter(project, b);
                 }
-                visitor.visit( b );
+                visitor.visit(b);
             }
         }
     }
 
-
     private ISigilBundle compileTimeFilter(ISigilProjectModel project, ISigilBundle bundle)
     {
         bundle = (ISigilBundle) bundle.clone();
 
         Collection<String> packages = findPackages(project);
-        
-        for ( IPackageExport pe : bundle.getBundleInfo().getExports() ) {
+
+        for (IPackageExport pe : bundle.getBundleInfo().getExports())
+        {
             final String packagePath = pe.getPackageName().replace('.', '/');
-            if ( !packages.contains(packagePath) ) {
+            if (!packages.contains(packagePath))
+            {
                 bundle.getBundleInfo().removeExport(pe);
             }
         }
-        
+
         return bundle;
     }
 
-
-
     private Collection<String> findPackages(ISigilProjectModel project)
     {
         final IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
         final IContentType javaContentType = contentTypeManager.getContentType("org.eclipse.jdt.core.javaSource");
         final HashSet<String> packages = new HashSet<String>();
-        
+
         try
         {
             project.getProject().accept(new IResourceVisitor()
             {
                 public boolean visit(IResource resource) throws CoreException
                 {
-                    if ( resource instanceof IFile ) {
+                    if (resource instanceof IFile)
+                    {
                         IFile f = (IFile) resource;
                         IContentType ct = contentTypeManager.findContentTypeFor(f.getName());
-                        if ( ct != null && ct.isKindOf(javaContentType) ) {
+                        if (ct != null && ct.isKindOf(javaContentType))
+                        {
                             IPath p = f.getProjectRelativePath();
                             p = p.removeLastSegments(1);
                             p = p.removeFirstSegments(1);
-                            packages.add( p.toString() );
+                            packages.add(p.toString());
                         }
                     }
-                    
+
                     return true;
                 }
             });
         }
         catch (CoreException e)
         {
-            SigilCore.error( "Failed to read packages for " + project.getProject().getName() );
+            SigilCore.error("Failed to read packages for "
+                + project.getProject().getName());
         }
-        
+
         return packages;
-     }
-
-
+    }
 
     public void refresh()
     {
@@ -143,11 +144,12 @@
         // potential performance improvement in future?
     }
 
-    public void resourceChanged( IResourceChangeEvent event )
+    public void resourceChanged(IResourceChangeEvent event)
     {
         try
         {
-            switch (event.getType()) {
+            switch (event.getType())
+            {
                 case IResourceChangeEvent.PRE_DELETE:
                     handleDelete(event);
                     break;
@@ -159,9 +161,9 @@
                     break;
             }
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Workspace repository update failed", e );
+            SigilCore.error("Workspace repository update failed", e);
         }
     }
 
@@ -169,21 +171,22 @@
 
     private void handleDelete(IResourceChangeEvent event)
     {
-        if ( event.getResource() instanceof IProject ) {
+        if (event.getResource() instanceof IProject)
+        {
             IProject project = (IProject) event.getResource();
-            if ( isSigilProject(project) )
+            if (isSigilProject(project))
             {
                 deleted.add(project);
             }
         }
     }
 
-
     private void handleRefresh(IResourceChangeEvent event)
     {
-        if ( event.getResource() instanceof IProject ) {
+        if (event.getResource() instanceof IProject)
+        {
             IProject project = (IProject) event.getResource();
-            if ( isSigilProject(project) )
+            if (isSigilProject(project))
             {
                 SigilCore.log("Refreshing workspace repository");
                 notifyChange();
@@ -191,28 +194,27 @@
         }
     }
 
-
     private void handleChange(IResourceChangeEvent event) throws CoreException
     {
         final boolean[] notify = new boolean[1];
-        
-        event.getDelta().accept( new IResourceDeltaVisitor()
+
+        event.getDelta().accept(new IResourceDeltaVisitor()
         {
-            public boolean visit( IResourceDelta delta ) throws CoreException
+            public boolean visit(IResourceDelta delta) throws CoreException
             {
                 boolean checkMembers = true;
 
                 IResource resource = delta.getResource();
-                if ( resource instanceof IProject )
+                if (resource instanceof IProject)
                 {
-                    IProject project = ( IProject ) resource;
-                    if ( isSigilProject(project) )
+                    IProject project = (IProject) resource;
+                    if (isSigilProject(project))
                     {
-                        switch ( delta.getKind() )
+                        switch (delta.getKind())
                         {
                             case IResourceDelta.CHANGED:
                                 int flag = delta.getFlags();
-                                if ( ( flag & UPDATE_MASK ) == 0 )
+                                if ((flag & UPDATE_MASK) == 0)
                                 {
                                     break;
                                 }
@@ -230,9 +232,9 @@
                         checkMembers = false;
                     }
                 }
-                else if ( resource.getName().equals( SigilCore.SIGIL_PROJECT_FILE ) )
+                else if (resource.getName().equals(SigilCore.SIGIL_PROJECT_FILE))
                 {
-                    switch ( delta.getKind() )
+                    switch (delta.getKind())
                     {
                         case IResourceDelta.CHANGED:
                         case IResourceDelta.ADDED:
@@ -243,17 +245,17 @@
                 }
                 return checkMembers && !notify[0];
             }
-        } );
-        
-        if (notify[0]) {
+        });
+
+        if (notify[0])
+        {
             notifyChange();
         }
     }
 
-
     private boolean isSigilProject(IProject project)
     {
-        return SigilCore.isSigilProject( project ) || deleted.remove(project);
+        return SigilCore.isSigilProject(project) || deleted.remove(project);
     }
 
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java
index d9c723b..0562ebf 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java
@@ -19,31 +19,28 @@
 
 package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
 
-
 import java.util.Properties;
 
 import org.apache.felix.sigil.common.repository.IBundleRepository;
 import org.apache.felix.sigil.common.repository.IRepositoryProvider;
 import org.eclipse.core.resources.ResourcesPlugin;
 
-
 public class WorkspaceRepositoryProvider implements IRepositoryProvider
 {
     private static WorkspaceRepository repository;
 
-
     public static WorkspaceRepository getWorkspaceRepository()
     {
         return repository;
     }
 
-
-    public IBundleRepository createRepository( String id, Properties preferences )
+    public IBundleRepository createRepository(String id, Properties preferences)
     {
-        if ( repository == null )
+        if (repository == null)
         {
-            repository = new WorkspaceRepository( id );
-            ResourcesPlugin.getWorkspace().addResourceChangeListener( repository, WorkspaceRepository.EVENT_MASKS );            
+            repository = new WorkspaceRepository(id);
+            ResourcesPlugin.getWorkspace().addResourceChangeListener(repository,
+                WorkspaceRepository.EVENT_MASKS);
         }
         return repository;
     }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
index 377f575..340f95e 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
@@ -34,6 +34,7 @@
 import org.eclipse.core.resources.IResourceDeltaVisitor;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
+
 //import org.eclipse.core.runtime.IProgressMonitor;
 //import org.eclipse.core.runtime.IStatus;
 //import org.eclipse.core.runtime.Status;
@@ -41,7 +42,8 @@
 
 public class ProjectResourceListener implements IResourceChangeListener
 {
-    public static final int EVENT_MASKS = IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_CHANGE;
+    public static final int EVENT_MASKS = IResourceChangeEvent.PRE_DELETE
+        | IResourceChangeEvent.POST_CHANGE;
     private final SigilProjectManager projectManager;
 
     public ProjectResourceListener(SigilProjectManager projectManager)
@@ -49,11 +51,12 @@
         this.projectManager = projectManager;
     }
 
-    public void resourceChanged( IResourceChangeEvent event )
+    public void resourceChanged(IResourceChangeEvent event)
     {
         try
         {
-            switch ( event.getType() ) {
+            switch (event.getType())
+            {
                 case IResourceChangeEvent.PRE_REFRESH:
                     handleRefresh(event);
                     break;
@@ -64,40 +67,43 @@
                     handlePostChange(event);
                     break;
             }
-            
+
             handleUpdate();
         }
         catch (CoreException e)
         {
-            SigilCore.error( "Failed to process resource change", e );
+            SigilCore.error("Failed to process resource change", e);
         }
     }
 
     private void handleUpdate()
     {
-        if( capabilities.size() > 0 ) {
-            final LinkedList<ICapabilityModelElement> changes = new LinkedList<ICapabilityModelElement>(capabilities);
+        if (capabilities.size() > 0)
+        {
+            final LinkedList<ICapabilityModelElement> changes = new LinkedList<ICapabilityModelElement>(
+                capabilities);
             capabilities.clear();
-            
-            ResolveProjectsJob job = new ResolveProjectsJob(ResourcesPlugin.getWorkspace(), changes);
-            job.schedule();        
+
+            ResolveProjectsJob job = new ResolveProjectsJob(
+                ResourcesPlugin.getWorkspace(), changes);
+            job.schedule();
         }
     }
-    
+
     private void handleRefresh(IResourceChangeEvent event) throws CoreException
     {
         IResourceDelta delta = event.getDelta();
-        if ( delta != null )
+        if (delta != null)
         {
-            delta.accept( new IResourceDeltaVisitor()
+            delta.accept(new IResourceDeltaVisitor()
             {
-                public boolean visit( IResourceDelta delta ) throws CoreException
+                public boolean visit(IResourceDelta delta) throws CoreException
                 {
                     IResource resource = delta.getResource();
-                    if ( resource instanceof IProject )
+                    if (resource instanceof IProject)
                     {
-                        IProject project = ( IProject ) resource;
-                        if ( SigilCore.isSigilProject( project ) )
+                        IProject project = (IProject) resource;
+                        if (SigilCore.isSigilProject(project))
                         {
                             readCapabilities(project);
                         }
@@ -106,28 +112,28 @@
                     }
                     return true;
                 }
-            } );            
+            });
         }
-    }    
+    }
 
     private LinkedList<ICapabilityModelElement> capabilities = new LinkedList<ICapabilityModelElement>();
-    
+
     private void handlePostChange(IResourceChangeEvent event) throws CoreException
     {
         IResourceDelta delta = event.getDelta();
-        if ( delta != null )
+        if (delta != null)
         {
-            delta.accept( new IResourceDeltaVisitor()
+            delta.accept(new IResourceDeltaVisitor()
             {
-                public boolean visit( IResourceDelta delta ) throws CoreException
+                public boolean visit(IResourceDelta delta) throws CoreException
                 {
                     IResource resource = delta.getResource();
-                    if ( resource instanceof IProject )
+                    if (resource instanceof IProject)
                     {
-                        IProject project = ( IProject ) resource;
-                        if ( SigilCore.isSigilProject( project ) )
+                        IProject project = (IProject) resource;
+                        if (SigilCore.isSigilProject(project))
                         {
-                            switch ( delta.getKind() )
+                            switch (delta.getKind())
                             {
                                 case IResourceDelta.REMOVED:
                                 case IResourceDelta.ADDED:
@@ -140,17 +146,17 @@
                     }
                     return true;
                 }
-            } );            
+            });
         }
     }
 
     protected void handlePreDelete(IResourceChangeEvent event) throws CoreException
     {
         IResource resource = event.getResource();
-        if ( resource instanceof IProject )
+        if (resource instanceof IProject)
         {
-            IProject project = ( IProject ) resource;
-            if ( SigilCore.isSigilProject( project ) )
+            IProject project = (IProject) resource;
+            if (SigilCore.isSigilProject(project))
             {
                 readCapabilities(project);
                 projectManager.flushSigilProject(project);
@@ -162,10 +168,11 @@
     {
         ISigilProjectModel sigil = SigilCore.create(project);
         sigil.visit(new IModelWalker()
-        { 
+        {
             public boolean visit(IModelElement element)
             {
-                if ( element instanceof ICapabilityModelElement ) {
+                if (element instanceof ICapabilityModelElement)
+                {
                     capabilities.add((ICapabilityModelElement) element);
                 }
                 return true;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/SigilProjectManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/SigilProjectManager.java
index 7b734f7..03a8826 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/SigilProjectManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/SigilProjectManager.java
@@ -28,28 +28,34 @@
 public class SigilProjectManager
 {
     private static HashMap<IProject, SigilProject> projects = new HashMap<IProject, SigilProject>();
-    
-    public SigilProject getSigilProject(IProject project) throws CoreException {
-        if ( project.hasNature( SigilCore.NATURE_ID ) )
+
+    public SigilProject getSigilProject(IProject project) throws CoreException
+    {
+        if (project.hasNature(SigilCore.NATURE_ID))
         {
             SigilProject p = null;
-            synchronized( projects ) {
+            synchronized (projects)
+            {
                 p = projects.get(project);
-                if ( p == null ) {
-                   p = new SigilProject( project );
-                   projects.put(project, p);
+                if (p == null)
+                {
+                    p = new SigilProject(project);
+                    projects.put(project, p);
                 }
             }
-            return p; 
+            return p;
         }
         else
         {
-            throw SigilCore.newCoreException( "Project " + project.getName() + " is not a sigil project", null );
+            throw SigilCore.newCoreException("Project " + project.getName()
+                + " is not a sigil project", null);
         }
     }
-    
-    public void flushSigilProject(IProject project) {
-        synchronized(project) {
+
+    public void flushSigilProject(IProject project)
+    {
+        synchronized (project)
+        {
             projects.remove(project);
         }
     }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
index bb9be60..e444918 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.job;
 
-
 import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
@@ -38,32 +37,31 @@
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.MultiStatus;
 
-
 public class ResolveProjectsJob extends WorkspaceJob
 {
     private final Collection<ISigilProjectModel> sigilProjects;
     private final LinkedList<ICapabilityModelElement> capabilities;
-    
-    public ResolveProjectsJob( IWorkspace workspace )
+
+    public ResolveProjectsJob(IWorkspace workspace)
     {
-        super( "Resolving Sigil projects" );
-        setRule( workspace.getRoot() );
+        super("Resolving Sigil projects");
+        setRule(workspace.getRoot());
         sigilProjects = SigilCore.getRoot().getProjects();
         capabilities = null;
     }
 
     public ResolveProjectsJob(IWorkspace workspace, LinkedList<ICapabilityModelElement> capabilities)
     {
-        super( "Resolving Sigil projects" );
+        super("Resolving Sigil projects");
         this.capabilities = capabilities;
-        setRule( workspace.getRoot() );
+        setRule(workspace.getRoot());
         sigilProjects = SigilCore.getRoot().getProjects();
     }
 
     public ResolveProjectsJob(ISigilProjectModel project)
     {
-        super( "Resolving Sigil project" );
-        setRule( project.getProject().getWorkspace().getRoot() );
+        super("Resolving Sigil project");
+        setRule(project.getProject().getWorkspace().getRoot());
         sigilProjects = Collections.singleton(project);
         capabilities = null;
     }
@@ -71,22 +69,25 @@
     @Override
     public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
     {
-        MultiStatus status = new MultiStatus( SigilCore.PLUGIN_ID, 0, "Error resolving Sigil projects", null );
+        MultiStatus status = new MultiStatus(SigilCore.PLUGIN_ID, 0,
+            "Error resolving Sigil projects", null);
 
         boolean flush = sigilProjects.size() > 0;
-        
-        for ( ISigilProjectModel sigilProject : sigilProjects )
+
+        for (ISigilProjectModel sigilProject : sigilProjects)
         {
             try
             {
-                if ( isDependent(sigilProject) ) { 
-                    if ( flush) sigilProject.flushDependencyState();
+                if (isDependent(sigilProject))
+                {
+                    if (flush)
+                        sigilProject.flushDependencyState();
                     sigilProject.rebuildDependencies(monitor);
                 }
             }
-            catch ( CoreException e )
+            catch (CoreException e)
             {
-                status.add( e.getStatus() );
+                status.add(e.getStatus());
             }
         }
 
@@ -95,27 +96,34 @@
 
     private boolean isDependent(ISigilProjectModel sigilProject)
     {
-        if ( capabilities == null ) {
+        if (capabilities == null)
+        {
             return true;
         }
-        else {
+        else
+        {
             ISigilBundle b = sigilProject.getBundle();
-            if ( b == null ) {
+            if (b == null)
+            {
                 // sigil project deleted can't be a dependent
                 return false;
             }
-            else {
+            else
+            {
                 final boolean[] dep = new boolean[1];
-                
+
                 b.visit(new IModelWalker()
                 {
                     public boolean visit(IModelElement element)
                     {
-                        if (element instanceof IRequirementModelElement) {
+                        if (element instanceof IRequirementModelElement)
+                        {
                             IRequirementModelElement r = (IRequirementModelElement) element;
-        
-                            for (ICapabilityModelElement c : capabilities) {
-                                if( r.accepts(c)) {
+
+                            for (ICapabilityModelElement c : capabilities)
+                            {
+                                if (r.accepts(c))
+                                {
                                     dep[0] = true;
                                     break;
                                 }
@@ -125,7 +133,7 @@
                         return !dep[0];
                     }
                 });
-                
+
                 return dep[0];
             }
         }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java
index e60be3f..033ba92 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java
@@ -19,21 +19,17 @@
 
 package org.apache.felix.sigil.eclipse.job;
 
-
 import org.eclipse.core.runtime.IProgressMonitor;
 
-
 public class ThreadProgressMonitor
 {
     private static ThreadLocal<IProgressMonitor> local = new ThreadLocal<IProgressMonitor>();
 
-
-    public static void setProgressMonitor( IProgressMonitor monitor )
+    public static void setProgressMonitor(IProgressMonitor monitor)
     {
-        local.set( monitor );
+        local.set(monitor);
     }
 
-
     public static IProgressMonitor getProgressMonitor()
     {
         return local.get();
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java
index 0570da8..4544c88 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.model.project;
 
-
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
@@ -30,15 +29,14 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 
-
 public interface ISigilModelRoot
 {
     List<ISigilProjectModel> getProjects();
 
+    Set<ISigilProjectModel> resolveDependentProjects(
+        Collection<ICapabilityModelElement> caps, IProgressMonitor monitor);
 
-    Set<ISigilProjectModel> resolveDependentProjects( Collection<ICapabilityModelElement> caps, IProgressMonitor monitor );
-
-
-    Collection<ISigilBundle> resolveBundles( ISigilProjectModel sigil, IModelElement element, boolean includeOptional,
-        IProgressMonitor monitor ) throws CoreException;
+    Collection<ISigilBundle> resolveBundles(ISigilProjectModel sigil,
+        IModelElement element, boolean includeOptional, IProgressMonitor monitor)
+        throws CoreException;
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java
index 60afe17..0b80c5b 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.eclipse.model.project;
 
-
 import java.util.Collection;
 
-
 import org.apache.felix.sigil.common.config.IBldProject;
 import org.apache.felix.sigil.common.core.BldCore;
 import org.apache.felix.sigil.common.model.ICompoundModelElement;
@@ -39,7 +37,6 @@
 import org.osgi.framework.Version;
 import org.osgi.service.prefs.Preferences;
 
-
 /**
  * Represents a sigil project. To get a reference to a ISigilProjectModel you can use the 
  * helper method {@link BldCore#create(IProject)}.
@@ -55,14 +52,11 @@
      */
     IProject getProject();
 
-
     // shortcut to getProject().getName()
     String getName();
 
-
     Preferences getPreferences();
 
-
     /**
      * 
      * @param monitor
@@ -73,64 +67,52 @@
      * @throws CoreException
      */
     void save(IProgressMonitor monitor) throws CoreException;
-    
+
     /**
      * Save the project and optionally rebuildDependencies
      * @param monitor
      * @param rebuildDependencies
      * @throws CoreException
      */
-    void save( IProgressMonitor monitor, boolean rebuildDependencies ) throws CoreException;
-    
-    void rebuildDependencies(IProgressMonitor monitor) throws CoreException;
-    
-    void flushDependencyState();
+    void save(IProgressMonitor monitor, boolean rebuildDependencies) throws CoreException;
 
+    void rebuildDependencies(IProgressMonitor monitor) throws CoreException;
+
+    void flushDependencyState();
 
     /**
      * @return
      */
     Version getVersion();
 
-
     String getSymbolicName();
 
-
     ISigilBundle getBundle();
 
-
-    void setBundle( ISigilBundle bundle );
-
+    void setBundle(ISigilBundle bundle);
 
     /**
      * @return
      */
     IJavaProject getJavaModel();
 
-
-    void resetClasspath( IProgressMonitor monitor ) throws CoreException;
-
+    void resetClasspath(IProgressMonitor monitor) throws CoreException;
 
     IPath findBundleLocation() throws CoreException;
 
+    IModelElement findImport(String packageName, IProgressMonitor monitor);
 
-    IModelElement findImport( String packageName, IProgressMonitor monitor );
+    boolean isInClasspath(String packageName, IProgressMonitor monitor)
+        throws CoreException;
 
+    boolean isInClasspath(ISigilBundle bundle);
 
-    boolean isInClasspath( String packageName, IProgressMonitor monitor ) throws CoreException;
-
-
-    boolean isInClasspath( ISigilBundle bundle );
-
-
-    boolean isInBundleClasspath( IPackageFragment root ) throws JavaModelException;
-
+    boolean isInBundleClasspath(IPackageFragment root) throws JavaModelException;
 
     IPath findOutputLocation() throws CoreException;
 
-
     IBldProject getBldProject() throws CoreException;
 
-
-    Collection<IClasspathEntry> findExternalClasspath( IProgressMonitor monitor ) throws CoreException;
+    Collection<IClasspathEntry> findExternalClasspath(IProgressMonitor monitor)
+        throws CoreException;
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java
index bcba18b..f3683b6 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java
@@ -19,43 +19,32 @@
 
 package org.apache.felix.sigil.eclipse.model.repository;
 
-
 import java.util.List;
 import java.util.Map;
 
 import org.apache.felix.sigil.eclipse.internal.model.repository.RepositoryType;
 import org.eclipse.core.runtime.CoreException;
 
-
 public interface IRepositoryConfiguration
 {
 
     List<IRepositoryModel> loadRepositories();
 
+    IRepositoryModel findRepository(String id);
 
-    IRepositoryModel findRepository( String id );
-
-
-    void saveRepositories( List<IRepositoryModel> repositories ) throws CoreException;
-
+    void saveRepositories(List<IRepositoryModel> repositories) throws CoreException;
 
     List<RepositoryType> loadRepositoryTypes();
 
-
-    IRepositoryModel newRepositoryElement( IRepositoryType type );
-
+    IRepositoryModel newRepositoryElement(IRepositoryType type);
 
     IRepositorySet getDefaultRepositorySet();
 
+    void setDefaultRepositorySet(IRepositorySet defaultSet);
 
-    void setDefaultRepositorySet( IRepositorySet defaultSet );
-
-
-    IRepositorySet getRepositorySet( String name );
-
+    IRepositorySet getRepositorySet(String name);
 
     Map<String, IRepositorySet> loadRepositorySets();
 
-
-    void saveRepositorySets( Map<String, IRepositorySet> sets );
+    void saveRepositorySets(Map<String, IRepositorySet> sets);
 }
\ No newline at end of file
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java
index 37f2649..89c8671 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java
@@ -19,24 +19,18 @@
 
 package org.apache.felix.sigil.eclipse.model.repository;
 
-
 import org.eclipse.jface.preference.PreferenceStore;
 
-
 public interface IRepositoryModel
 {
 
     String getId();
 
-
-    void setName( String stringValue );
-
+    void setName(String stringValue);
 
     String getName();
 
-
     PreferenceStore getPreferences();
 
-
     IRepositoryType getType();
 }
\ No newline at end of file
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java
index d28f5e2..8ebb46c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java
@@ -19,17 +19,13 @@
 
 package org.apache.felix.sigil.eclipse.model.repository;
 
-
 public interface IRepositorySet
 {
-    void setRepository( IRepositoryModel id, int position );
+    void setRepository(IRepositoryModel id, int position);
 
-
-    void removeRepository( IRepositoryModel id );
-
+    void removeRepository(IRepositoryModel id);
 
     IRepositoryModel[] getRepositories();
 
-
-    void setRepositories( IRepositoryModel[] repositories );
+    void setRepositories(IRepositoryModel[] repositories);
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java
index f25f2d8..d56ba7c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java
@@ -19,22 +19,17 @@
 
 package org.apache.felix.sigil.eclipse.model.repository;
 
-
 import org.eclipse.swt.graphics.Image;
 
-
 public interface IRepositoryType
 {
 
     String getType();
 
-
     String getId();
 
-
     Image getIcon();
 
-
     boolean isDynamic();
 
 }
\ No newline at end of file
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java
index c3cb1a6..1d80a8a 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.model.repository;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 
-
 public class RepositorySet implements IRepositorySet
 {
 
@@ -31,49 +29,42 @@
 
     private IRepositoryModel[] reps;
 
-
     public RepositorySet()
     {
-        this( EMPTY );
+        this(EMPTY);
     }
 
-
-    public RepositorySet( Collection<IRepositoryModel> reps )
+    public RepositorySet(Collection<IRepositoryModel> reps)
     {
-        this( reps.toArray( new IRepositoryModel[reps.size()] ) );
+        this(reps.toArray(new IRepositoryModel[reps.size()]));
     }
 
-
-    public RepositorySet( IRepositoryModel[] repositories )
+    public RepositorySet(IRepositoryModel[] repositories)
     {
         this.reps = repositories;
     }
 
-
-    public void setRepository( IRepositoryModel id, int position )
+    public void setRepository(IRepositoryModel id, int position)
     {
-        ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>( reps.length + 1 );
-        tmp.remove( id );
-        tmp.add( position, id );
-        reps = tmp.toArray( new IRepositoryModel[tmp.size()] );
+        ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>(reps.length + 1);
+        tmp.remove(id);
+        tmp.add(position, id);
+        reps = tmp.toArray(new IRepositoryModel[tmp.size()]);
     }
 
-
     public IRepositoryModel[] getRepositories()
     {
         return reps;
     }
 
-
-    public void removeRepository( IRepositoryModel id )
+    public void removeRepository(IRepositoryModel id)
     {
-        ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>( reps.length + 1 );
-        tmp.remove( id );
-        reps = tmp.toArray( new IRepositoryModel[tmp.size()] );
+        ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>(reps.length + 1);
+        tmp.remove(id);
+        reps = tmp.toArray(new IRepositoryModel[tmp.size()]);
     }
 
-
-    public void setRepositories( IRepositoryModel[] repositories )
+    public void setRepositories(IRepositoryModel[] repositories)
     {
         reps = repositories == null ? EMPTY : repositories;
     }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java
index 036f06c..01faa5c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.model.util;
 
-
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.nio.CharBuffer;
@@ -35,12 +34,11 @@
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 
-
 public class Grep
 {
 
     // Pattern used to parse lines
-    private static Pattern linePattern = Pattern.compile( ".*\r?\n" );
+    private static Pattern linePattern = Pattern.compile(".*\r?\n");
 
     // The input pattern that we're looking for
     private Pattern pattern;
@@ -49,77 +47,72 @@
 
     private FileChannel fc;
 
-
-    private Grep( IFile f, Pattern pattern ) throws IOException, CoreException
+    private Grep(IFile f, Pattern pattern) throws IOException, CoreException
     {
         this.pattern = pattern;
-        cb = openBuffer( f );
+        cb = openBuffer(f);
     }
 
-
-    private CharBuffer openBuffer( IFile f ) throws IOException, CoreException
+    private CharBuffer openBuffer(IFile f) throws IOException, CoreException
     {
-        Charset charset = Charset.forName( f.getCharset() );
+        Charset charset = Charset.forName(f.getCharset());
         CharsetDecoder decoder = charset.newDecoder();
         // Open the file and then get a channel from the stream
-        FileInputStream fis = new FileInputStream( f.getLocation().toFile() );
+        FileInputStream fis = new FileInputStream(f.getLocation().toFile());
         fc = fis.getChannel();
 
         // Get the file's size and then map it into memory
-        int sz = ( int ) fc.size();
-        MappedByteBuffer bb = fc.map( FileChannel.MapMode.READ_ONLY, 0, sz );
+        int sz = (int) fc.size();
+        MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);
 
         // Decode the file into a char buffer
-        return decoder.decode( bb );
+        return decoder.decode(bb);
     }
 
-
-    public static String[] grep( Pattern pattern, IFile... files ) throws CoreException
+    public static String[] grep(Pattern pattern, IFile... files) throws CoreException
     {
         LinkedList<String> matches = new LinkedList<String>();
-        for ( IFile f : files )
+        for (IFile f : files)
         {
             try
             {
-                Grep g = new Grep( f, pattern );
-                g.grep( matches );
+                Grep g = new Grep(f, pattern);
+                g.grep(matches);
                 g.close();
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
         }
-        return matches.toArray( new String[matches.size()] );
+        return matches.toArray(new String[matches.size()]);
     }
 
-
     private void close() throws IOException
     {
         fc.close();
     }
 
-
     // Use the linePattern to break the given CharBuffer into lines, applying
     // the input pattern to each line to see if we have a match
     //
-    private void grep( List<String> matches )
+    private void grep(List<String> matches)
     {
-        Matcher lm = linePattern.matcher( cb ); // Line matcher
+        Matcher lm = linePattern.matcher(cb); // Line matcher
         Matcher pm = null; // Pattern matcher
         int lines = 0;
-        while ( lm.find() )
+        while (lm.find())
         {
             lines++;
             CharSequence cs = lm.group(); // The current line
-            if ( pm == null )
-                pm = pattern.matcher( cs );
+            if (pm == null)
+                pm = pattern.matcher(cs);
             else
-                pm.reset( cs );
-            if ( pm.find() )
-                matches.add( pm.group() );
-            if ( lm.end() == cb.limit() )
+                pm.reset(cs);
+            if (pm.find())
+                matches.add(pm.group());
+            if (lm.end() == cb.limit())
                 break;
         }
     }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
index 3a4d774..c01c9d2 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.model.util;
 
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -94,7 +93,6 @@
 import org.eclipse.jdt.core.Signature;
 import org.osgi.framework.Version;
 
-
 /**
  * @author dave
  *
@@ -102,31 +100,30 @@
 public class JavaHelper
 {
 
-    public static final IAccessRule DENY_RULE = JavaCore.newAccessRule( new Path( "**" ), IAccessRule.K_NON_ACCESSIBLE
-        | IAccessRule.IGNORE_IF_BETTER );
+    public static final IAccessRule DENY_RULE = JavaCore.newAccessRule(new Path("**"),
+        IAccessRule.K_NON_ACCESSIBLE | IAccessRule.IGNORE_IF_BETTER);
 
-    public static final IAccessRule ALLOW_ALL_RULE = JavaCore
-        .newAccessRule( new Path( "**" ), IAccessRule.K_ACCESSIBLE );
+    public static final IAccessRule ALLOW_ALL_RULE = JavaCore.newAccessRule(
+        new Path("**"), IAccessRule.K_ACCESSIBLE);
 
     private static Map<String, Collection<IClasspathEntry>> entryCache = new HashMap<String, Collection<IClasspathEntry>>();
 
-
-    public static Collection<IClasspathEntry> findClasspathEntries( ISigilBundle bundle )
+    public static Collection<IClasspathEntry> findClasspathEntries(ISigilBundle bundle)
     {
         LinkedList<IClasspathEntry> cp = new LinkedList<IClasspathEntry>();
 
-        ISigilProjectModel sp = bundle.getAncestor( ISigilProjectModel.class );
+        ISigilProjectModel sp = bundle.getAncestor(ISigilProjectModel.class);
 
-        if ( sp != null )
+        if (sp != null)
         {
             IJavaProject p = sp.getJavaModel();
 
-            for ( String enc : bundle.getClasspathEntrys() )
+            for (String enc : bundle.getClasspathEntrys())
             {
-                IClasspathEntry e = p.decodeClasspathEntry( enc );
-                if ( e != null )
+                IClasspathEntry e = p.decodeClasspathEntry(enc);
+                if (e != null)
                 {
-                    cp.add( e );
+                    cp.add(e);
                 }
             }
         }
@@ -134,25 +131,24 @@
         return cp;
     }
 
-
-    public static Collection<ICompilationUnit> findCompilationUnits( ISigilProjectModel project )
-        throws JavaModelException
+    public static Collection<ICompilationUnit> findCompilationUnits(
+        ISigilProjectModel project) throws JavaModelException
     {
         LinkedList<ICompilationUnit> ret = new LinkedList<ICompilationUnit>();
 
         IJavaProject java = project.getJavaModel();
-        for ( IClasspathEntry cp : findClasspathEntries( project.getBundle() ) )
+        for (IClasspathEntry cp : findClasspathEntries(project.getBundle()))
         {
-            IPackageFragmentRoot[] roots = java.findPackageFragmentRoots( cp );
-            for ( IPackageFragmentRoot rt : roots )
+            IPackageFragmentRoot[] roots = java.findPackageFragmentRoots(cp);
+            for (IPackageFragmentRoot rt : roots)
             {
-                for ( IJavaElement j : rt.getChildren() )
+                for (IJavaElement j : rt.getChildren())
                 {
-                    IPackageFragment p = ( IPackageFragment ) j;
+                    IPackageFragment p = (IPackageFragment) j;
                     ICompilationUnit[] units = p.getCompilationUnits();
-                    for ( ICompilationUnit u : units )
+                    for (ICompilationUnit u : units)
                     {
-                        ret.add( u );
+                        ret.add(u);
                     }
                 }
             }
@@ -161,126 +157,126 @@
         return ret;
     }
 
-
     /**
      * @param project 
      * @param packageName
      * @return
      */
-    public static Collection<IPackageExport> findExportsForPackage( ISigilProjectModel project, final String packageName )
+    public static Collection<IPackageExport> findExportsForPackage(
+        ISigilProjectModel project, final String packageName)
     {
         final LinkedList<IPackageExport> results = new LinkedList<IPackageExport>();
 
-        SigilCore.getRepositoryManager( project ).visit( new IModelWalker()
+        SigilCore.getRepositoryManager(project).visit(new IModelWalker()
         {
-            public boolean visit( IModelElement element )
+            public boolean visit(IModelElement element)
             {
-                if ( element instanceof IPackageExport )
+                if (element instanceof IPackageExport)
                 {
-                    IPackageExport e = ( IPackageExport ) element;
-                    if ( e.getPackageName().equals( packageName ) )
+                    IPackageExport e = (IPackageExport) element;
+                    if (e.getPackageName().equals(packageName))
                     {
-                        results.add( e );
+                        results.add(e);
                     }
                 }
                 return true;
             }
-        } );
+        });
 
         return results;
     }
 
-
-    public static String[] findUses( String packageName, ISigilProjectModel projectModel ) throws CoreException
+    public static String[] findUses(String packageName, ISigilProjectModel projectModel)
+        throws CoreException
     {
         ArrayList<String> uses = new ArrayList<String>();
 
-        for ( final String dependency : findPackageDependencies( packageName, projectModel ) )
+        for (final String dependency : findPackageDependencies(packageName, projectModel))
         {
-            if ( !dependency.equals( packageName ) )
+            if (!dependency.equals(packageName))
             {
                 final boolean[] found = new boolean[1];
 
-                projectModel.visit( new IModelWalker()
+                projectModel.visit(new IModelWalker()
                 {
 
-                    public boolean visit( IModelElement element )
+                    public boolean visit(IModelElement element)
                     {
-                        if ( element instanceof IPackageImport )
+                        if (element instanceof IPackageImport)
                         {
-                            IPackageImport pi = ( IPackageImport ) element;
-                            if ( pi.getPackageName().equals( dependency ) )
+                            IPackageImport pi = (IPackageImport) element;
+                            if (pi.getPackageName().equals(dependency))
                             {
                                 found[0] = true;
                             }
                         }
                         return !found[0];
                     }
-                } );
+                });
 
-                if ( found[0] )
+                if (found[0])
                 {
-                    uses.add( dependency );
+                    uses.add(dependency);
                 }
             }
         }
 
-        return uses.toArray( new String[uses.size()] );
+        return uses.toArray(new String[uses.size()]);
     }
 
-
-    private static String[] findPackageDependencies( String packageName, ISigilProjectModel projectModel )
-        throws CoreException
+    private static String[] findPackageDependencies(String packageName,
+        ISigilProjectModel projectModel) throws CoreException
     {
         HashSet<String> imports = new HashSet<String>();
 
-        IPackageFragment p = ( IPackageFragment ) projectModel.getJavaModel().findElement(
-            new Path( packageName.replace( '.', '/' ) ) );
+        IPackageFragment p = (IPackageFragment) projectModel.getJavaModel().findElement(
+            new Path(packageName.replace('.', '/')));
 
-        if ( p == null )
+        if (p == null)
         {
-            throw SigilCore.newCoreException( "Unknown package " + packageName, null );
+            throw SigilCore.newCoreException("Unknown package " + packageName, null);
         }
-        for ( ICompilationUnit cu : p.getCompilationUnits() )
+        for (ICompilationUnit cu : p.getCompilationUnits())
         {
-            scanImports( cu, imports );
+            scanImports(cu, imports);
         }
-        for ( IClassFile cf : p.getClassFiles() )
+        for (IClassFile cf : p.getClassFiles())
         {
-            scanImports( cf, imports );
+            scanImports(cf, imports);
         }
 
-        return imports.toArray( new String[imports.size()] );
+        return imports.toArray(new String[imports.size()]);
     }
 
-
     /**
      * @param project
      * @param monitor
      * @return
      */
-    public static List<IPackageImport> findRequiredImports( ISigilProjectModel project, IProgressMonitor monitor )
+    public static List<IPackageImport> findRequiredImports(ISigilProjectModel project,
+        IProgressMonitor monitor)
     {
         LinkedList<IPackageImport> imports = new LinkedList<IPackageImport>();
 
-        for ( String packageName : findJavaImports( project, monitor ) )
+        for (String packageName : findJavaImports(project, monitor))
         {
-            if ( !ProfileManager.isBootDelegate( project, packageName ) )
+            if (!ProfileManager.isBootDelegate(project, packageName))
             { // these must come from boot classloader
                 try
                 {
-                    if ( !project.isInClasspath( packageName, monitor ) )
+                    if (!project.isInClasspath(packageName, monitor))
                     {
-                        Collection<IPackageExport> exports = findExportsForPackage( project, packageName );
-                        if ( !exports.isEmpty() )
+                        Collection<IPackageExport> exports = findExportsForPackage(
+                            project, packageName);
+                        if (!exports.isEmpty())
                         {
-                            imports.add( select( exports ) );
+                            imports.add(select(exports));
                         }
                     }
                 }
-                catch ( CoreException e )
+                catch (CoreException e)
                 {
-                    SigilCore.error( "Failed to check classpath", e );
+                    SigilCore.error("Failed to check classpath", e);
                 }
             }
         }
@@ -288,171 +284,175 @@
         return imports;
     }
 
-
     /**
      * @param project
      * @param monitor
      * @return
      */
-    public static Collection<IModelElement> findUnusedReferences( final ISigilProjectModel project,
-        final IProgressMonitor monitor )
+    public static Collection<IModelElement> findUnusedReferences(
+        final ISigilProjectModel project, final IProgressMonitor monitor)
     {
         final LinkedList<IModelElement> unused = new LinkedList<IModelElement>();
 
-        final Set<String> packages = findJavaImports( project, monitor );
+        final Set<String> packages = findJavaImports(project, monitor);
 
-        project.visit( new IModelWalker()
+        project.visit(new IModelWalker()
         {
-            public boolean visit( IModelElement element )
+            public boolean visit(IModelElement element)
             {
-                if ( element instanceof IPackageImport )
+                if (element instanceof IPackageImport)
                 {
-                    IPackageImport pi = ( IPackageImport ) element;
-                    if ( !packages.contains( pi.getPackageName() ) )
+                    IPackageImport pi = (IPackageImport) element;
+                    if (!packages.contains(pi.getPackageName()))
                     {
-                        unused.add( pi );
+                        unused.add(pi);
                     }
                 }
-                else if ( element instanceof IRequiredBundle )
+                else if (element instanceof IRequiredBundle)
                 {
-                    IRequiredBundle rb = ( IRequiredBundle ) element;
-                    IRepositoryManager manager = SigilCore.getRepositoryManager( project );
-                    ResolutionConfig config = new ResolutionConfig( ResolutionConfig.INCLUDE_OPTIONAL
-                        | ResolutionConfig.IGNORE_ERRORS );
+                    IRequiredBundle rb = (IRequiredBundle) element;
+                    IRepositoryManager manager = SigilCore.getRepositoryManager(project);
+                    ResolutionConfig config = new ResolutionConfig(
+                        ResolutionConfig.INCLUDE_OPTIONAL
+                            | ResolutionConfig.IGNORE_ERRORS);
                     try
                     {
-                        IResolution r = manager.getBundleResolver().resolve( rb, config,
-                            new ResolutionMonitorAdapter( monitor ) );
-                        ISigilBundle bundle = r.getProvider( rb );
+                        IResolution r = manager.getBundleResolver().resolve(rb, config,
+                            new ResolutionMonitorAdapter(monitor));
+                        ISigilBundle bundle = r.getProvider(rb);
                         boolean found = false;
-                        for ( IPackageExport pe : bundle.getBundleInfo().getExports() )
+                        for (IPackageExport pe : bundle.getBundleInfo().getExports())
                         {
-                            if ( packages.contains( pe.getPackageName() ) )
+                            if (packages.contains(pe.getPackageName()))
                             {
                                 found = true;
                                 break;
                             }
                         }
 
-                        if ( !found )
+                        if (!found)
                         {
-                            unused.add( rb );
+                            unused.add(rb);
                         }
                     }
-                    catch ( ResolutionException e )
+                    catch (ResolutionException e)
                     {
-                        SigilCore.error( "Failed to resolve " + rb, e );
+                        SigilCore.error("Failed to resolve " + rb, e);
                     }
                 }
                 return true;
             }
-        } );
+        });
 
         return unused;
     }
 
-
-    public static Collection<IClasspathEntry> resolveClasspathEntrys( ISigilProjectModel sigil,
-        IProgressMonitor monitor ) throws CoreException
+    public static Collection<IClasspathEntry> resolveClasspathEntrys(
+        ISigilProjectModel sigil, IProgressMonitor monitor) throws CoreException
     {
-        if ( monitor == null )
+        if (monitor == null)
         {
             monitor = Job.getJobManager().createProgressGroup();
-            monitor.beginTask( "Resolving classpath for " + sigil.getSymbolicName(), 2 );
+            monitor.beginTask("Resolving classpath for " + sigil.getSymbolicName(), 2);
         }
 
         ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
 
-        ResolutionConfig config = new ResolutionConfig( ResolutionConfig.INCLUDE_OPTIONAL
-            | ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INDEXED_ONLY | ResolutionConfig.LOCAL_ONLY | ResolutionConfig.COMPILE_TIME );
+        ResolutionConfig config = new ResolutionConfig(ResolutionConfig.INCLUDE_OPTIONAL
+            | ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INDEXED_ONLY
+            | ResolutionConfig.LOCAL_ONLY | ResolutionConfig.COMPILE_TIME);
 
         IResolution resolution;
         try
         {
-            resolution = SigilCore.getRepositoryManager( sigil ).getBundleResolver().resolve( sigil, config,
-                new ResolutionMonitorAdapter( monitor ) );
+            resolution = SigilCore.getRepositoryManager(sigil).getBundleResolver().resolve(
+                sigil, config, new ResolutionMonitorAdapter(monitor));
         }
-        catch ( ResolutionException e )
+        catch (ResolutionException e)
         {
-            throw SigilCore.newCoreException( "Failed to resolve dependencies", e );
+            throw SigilCore.newCoreException("Failed to resolve dependencies", e);
         }
 
-        monitor.worked( 1 );
+        monitor.worked(1);
 
         Set<ISigilBundle> bundles = resolution.getBundles();
-        for ( ISigilBundle bundle : bundles )
+        for (ISigilBundle bundle : bundles)
         {
-            if ( !sigil.getSymbolicName().equals(bundle.getBundleInfo().getSymbolicName()) )
+            if (!sigil.getSymbolicName().equals(bundle.getBundleInfo().getSymbolicName()))
             { // discard self reference...
-                List<IModelElement> matched = resolution.getMatchedRequirements( bundle );
-                for ( IClasspathEntry cpe : buildClassPathEntry( sigil, bundle, bundles, matched, monitor ) )
+                List<IModelElement> matched = resolution.getMatchedRequirements(bundle);
+                for (IClasspathEntry cpe : buildClassPathEntry(sigil, bundle, bundles,
+                    matched, monitor))
                 {
-                    entries.add( cpe );
+                    entries.add(cpe);
                 }
             }
         }
 
-        Collections.sort( entries, new Comparator<IClasspathEntry>()
+        Collections.sort(entries, new Comparator<IClasspathEntry>()
         {
-            public int compare( IClasspathEntry o1, IClasspathEntry o2 )
+            public int compare(IClasspathEntry o1, IClasspathEntry o2)
             {
-                return o1.toString().compareTo( o2.toString() );
+                return o1.toString().compareTo(o2.toString());
             }
-        } );
+        });
 
-        monitor.worked( 1 );
+        monitor.worked(1);
         monitor.done();
 
         return entries;
     }
 
-
-    private static Collection<IClasspathEntry> buildClassPathEntry( ISigilProjectModel project, ISigilBundle provider,
-        Set<ISigilBundle> all, List<IModelElement> requirements, IProgressMonitor monitor ) throws CoreException
+    private static Collection<IClasspathEntry> buildClassPathEntry(
+        ISigilProjectModel project, ISigilBundle provider, Set<ISigilBundle> all,
+        List<IModelElement> requirements, IProgressMonitor monitor) throws CoreException
     {
-        IAccessRule[] rules = buildAccessRules( project, provider, all, requirements );
+        IAccessRule[] rules = buildAccessRules(project, provider, all, requirements);
         IClasspathAttribute[] attrs = new IClasspathAttribute[0];
 
-        ISigilProjectModel other = provider.getAncestor( ISigilProjectModel.class );
+        ISigilProjectModel other = provider.getAncestor(ISigilProjectModel.class);
 
         try
         {
-            if ( other == null )
+            if (other == null)
             {
-                provider.synchronize( monitor );
-                return newBundleEntry( provider, rules, attrs, false );
+                provider.synchronize(monitor);
+                return newBundleEntry(provider, rules, attrs, false);
             }
             else
             {
-                return newProjectEntry( other, rules, attrs, false );
+                return newProjectEntry(other, rules, attrs, false);
             }
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
-            throw SigilCore.newCoreException( "Failed to synchronize " + provider, e );
+            throw SigilCore.newCoreException("Failed to synchronize " + provider, e);
         }
     }
 
-
-    private static Collection<IClasspathEntry> newProjectEntry( ISigilProjectModel n, IAccessRule[] rules,
-        IClasspathAttribute[] attributes, boolean export ) throws CoreException
+    private static Collection<IClasspathEntry> newProjectEntry(ISigilProjectModel n,
+        IAccessRule[] rules, IClasspathAttribute[] attributes, boolean export)
+        throws CoreException
     {
         ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
-        entries.add( JavaCore.newProjectEntry( n.getProject().getFullPath(), rules, false, attributes, export ) );
-        for ( IClasspathEntry e : n.getJavaModel().getRawClasspath() )
+        entries.add(JavaCore.newProjectEntry(n.getProject().getFullPath(), rules, false,
+            attributes, export));
+        for (IClasspathEntry e : n.getJavaModel().getRawClasspath())
         {
-            switch ( e.getEntryKind() )
+            switch (e.getEntryKind())
             {
                 case IClasspathEntry.CPE_LIBRARY:
-                    entries.add( JavaCore.newLibraryEntry( e.getPath(), e.getSourceAttachmentPath(), e
-                        .getSourceAttachmentRootPath(), rules, attributes, export ) );
+                    entries.add(JavaCore.newLibraryEntry(e.getPath(),
+                        e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(),
+                        rules, attributes, export));
                     break;
                 case IClasspathEntry.CPE_VARIABLE:
-                    IPath path = JavaCore.getResolvedVariablePath( e.getPath() );
-                    if ( path != null )
+                    IPath path = JavaCore.getResolvedVariablePath(e.getPath());
+                    if (path != null)
                     {
-                        entries.add( JavaCore.newLibraryEntry( path, e.getSourceAttachmentPath(), e
-                            .getSourceAttachmentRootPath(), rules, attributes, export ) );
+                        entries.add(JavaCore.newLibraryEntry(path,
+                            e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(),
+                            rules, attributes, export));
                     }
                     break;
             }
@@ -461,13 +461,13 @@
         return entries;
     }
 
-
-    private static Collection<IClasspathEntry> newBundleEntry( ISigilBundle bundle, IAccessRule[] rules,
-        IClasspathAttribute[] attributes, boolean exported ) throws CoreException
+    private static Collection<IClasspathEntry> newBundleEntry(ISigilBundle bundle,
+        IAccessRule[] rules, IClasspathAttribute[] attributes, boolean exported)
+        throws CoreException
     {
         String name = bundle.getBundleInfo().getSymbolicName();
 
-        if ( bundle.getBundleInfo().getVersion() != null )
+        if (bundle.getBundleInfo().getVersion() != null)
         {
             name += "_version_" + bundle.getBundleInfo().getVersion();
         }
@@ -476,148 +476,150 @@
 
         Collection<IClasspathEntry> entries = null;
 
-        synchronized ( entryCache )
+        synchronized (entryCache)
         {
-            entries = entryCache.get( cacheName );
+            entries = entryCache.get(cacheName);
 
-            if ( entries == null )
+            if (entries == null)
             {
                 IPath path = PathUtil.newPathIfExists(bundle.getLocation());
 
-                if ( path == null )
+                if (path == null)
                 {
-                    SigilCore.error( "Found null path for " + bundle.getSymbolicName() );
+                    SigilCore.error("Found null path for " + bundle.getSymbolicName());
                     entries = Collections.emptyList();
                 }
                 else
                 {
-                    entries = buildEntries( path, name, bundle, rules, attributes, exported );
+                    entries = buildEntries(path, name, bundle, rules, attributes,
+                        exported);
                 }
 
-                entryCache.put( cacheName, entries );
+                entryCache.put(cacheName, entries);
             }
         }
 
         return entries;
     }
 
-    private static IPath bundleCache = SigilCore.getDefault().getStateLocation().append( "bundle-cache" );
+    private static IPath bundleCache = SigilCore.getDefault().getStateLocation().append(
+        "bundle-cache");
 
-
-    public static boolean isCachedBundle( String bp )
+    public static boolean isCachedBundle(String bp)
     {
-        return bp.startsWith( bundleCache.toOSString() );
+        return bp.startsWith(bundleCache.toOSString());
     }
 
-
-    private static Collection<IClasspathEntry> buildEntries( IPath path, String name, ISigilBundle bundle,
-        IAccessRule[] rules, IClasspathAttribute[] attributes, boolean exported ) throws CoreException
+    private static Collection<IClasspathEntry> buildEntries(IPath path, String name,
+        ISigilBundle bundle, IAccessRule[] rules, IClasspathAttribute[] attributes,
+        boolean exported) throws CoreException
     {
-        if ( path.toFile().isDirectory() )
+        if (path.toFile().isDirectory())
         {
-            throw SigilCore.newCoreException( "Bundle location cannot be a directory", null );
+            throw SigilCore.newCoreException("Bundle location cannot be a directory",
+                null);
         }
         else
         {
             // ok it's a jar could contain libs etc
             try
             {
-                IPath cache = bundleCache.append( name );
+                IPath cache = bundleCache.append(name);
                 Collection<String> classpath = bundle.getBundleInfo().getClasspaths();
-                ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>( classpath.size() );
+                ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(
+                    classpath.size());
                 IPath source = PathUtil.newPathIfExists(bundle.getSourcePathLocation());
                 IPath rootPath = PathUtil.newPathIfNotNull(bundle.getSourceRootPath());
 
-                if ( source != null && !source.toFile().exists() )
+                if (source != null && !source.toFile().exists())
                 {
                     source = null;
                 }
 
-                if ( !classpath.isEmpty() )
+                if (!classpath.isEmpty())
                 {
-                    unpack( cache, bundle, classpath );
-                    for ( String cp : classpath )
+                    unpack(cache, bundle, classpath);
+                    for (String cp : classpath)
                     {
-                        IPath p = ".".equals( cp ) ? path : cache.append( cp );
-                        if ( p.toFile().exists() )
+                        IPath p = ".".equals(cp) ? path : cache.append(cp);
+                        if (p.toFile().exists())
                         {
-                            IClasspathEntry e = JavaCore.newLibraryEntry( p, source, rootPath, rules,
-                                attributes, exported );
-                            entries.add( e );
+                            IClasspathEntry e = JavaCore.newLibraryEntry(p, source,
+                                rootPath, rules, attributes, exported);
+                            entries.add(e);
                         }
                     }
                 }
                 else
                 { // default classpath is .
-                    IClasspathEntry e = JavaCore.newLibraryEntry( path, source, rootPath, rules,
-                        attributes, exported );
-                    entries.add( e );
+                    IClasspathEntry e = JavaCore.newLibraryEntry(path, source, rootPath,
+                        rules, attributes, exported);
+                    entries.add(e);
                 }
                 return entries;
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                throw SigilCore.newCoreException( "Failed to unpack bundle", e );
+                throw SigilCore.newCoreException("Failed to unpack bundle", e);
             }
         }
     }
 
     private static HashMap<IPath, Collection<String>> unpacked = new HashMap<IPath, Collection<String>>();
 
-
-    private static synchronized void unpack( IPath cache, ISigilBundle bundle, Collection<String> classpath )
-        throws IOException
+    private static synchronized void unpack(IPath cache, ISigilBundle bundle,
+        Collection<String> classpath) throws IOException
     {
-        Collection<String> check = unpacked.get( cache );
+        Collection<String> check = unpacked.get(cache);
 
-        if ( check == null || !check.equals( classpath ) )
+        if (check == null || !check.equals(classpath))
         {
-            if ( classpath.size() == 1 && classpath.contains( "." ) )
+            if (classpath.size() == 1 && classpath.contains("."))
             {
-                unpacked.put( cache, classpath );
+                unpacked.put(cache, classpath);
             }
             else
             {
                 // trim . from path to avoid check later in inClasspath
-                check = new HashSet<String>( classpath );
-                check.remove( "." );
+                check = new HashSet<String>(classpath);
+                check.remove(".");
 
-                File dir = createEmptyDir( cache );
+                File dir = createEmptyDir(cache);
                 FileInputStream fin = null;
                 try
                 {
-                    fin = new FileInputStream( bundle.getLocation() );
-                    JarInputStream in = new JarInputStream( fin );
+                    fin = new FileInputStream(bundle.getLocation());
+                    JarInputStream in = new JarInputStream(fin);
                     JarEntry entry;
-                    while ( ( entry = in.getNextJarEntry() ) != null )
+                    while ((entry = in.getNextJarEntry()) != null)
                     {
-                        if ( inClasspath( check, entry ) )
+                        if (inClasspath(check, entry))
                         {
-                            File f = new File( dir, entry.getName() );
-                            if ( entry.isDirectory() )
+                            File f = new File(dir, entry.getName());
+                            if (entry.isDirectory())
                             {
-                                createDir( f );
+                                createDir(f);
                             }
                             else
                             {
                                 try
                                 {
                                     File p = f.getParentFile();
-                                    createDir( p );
-                                    streamTo( in, f );
+                                    createDir(p);
+                                    streamTo(in, f);
                                 }
-                                catch ( RuntimeException e )
+                                catch (RuntimeException e)
                                 {
-                                    SigilCore.error( "Failed to unpack " + entry, e );
+                                    SigilCore.error("Failed to unpack " + entry, e);
                                 }
                             }
                         }
                     }
-                    unpacked.put( cache, classpath );
+                    unpacked.put(cache, classpath);
                 }
                 finally
                 {
-                    if ( fin != null )
+                    if (fin != null)
                     {
                         fin.close();
                     }
@@ -626,17 +628,16 @@
         }
     }
 
-
     /**
      * @param classpath
      * @param entry
      * @return
      */
-    private static boolean inClasspath( Collection<String> classpath, JarEntry entry )
+    private static boolean inClasspath(Collection<String> classpath, JarEntry entry)
     {
-        for ( String s : classpath )
+        for (String s : classpath)
         {
-            if ( entry.getName().startsWith( s ) )
+            if (entry.getName().startsWith(s))
             {
                 return true;
             }
@@ -644,31 +645,29 @@
         return false;
     }
 
-
-    private static void createDir( File p ) throws IOException
+    private static void createDir(File p) throws IOException
     {
-        if ( !p.exists() )
+        if (!p.exists())
         {
-            if ( !p.mkdirs() )
-                throw new IOException( "Failed to create directory " + p );
+            if (!p.mkdirs())
+                throw new IOException("Failed to create directory " + p);
         }
     }
 
-
-    private static void streamTo( InputStream in, File f ) throws IOException
+    private static void streamTo(InputStream in, File f) throws IOException
     {
-        FileOutputStream fos = new FileOutputStream( f );
+        FileOutputStream fos = new FileOutputStream(f);
         try
         {
             byte[] buf = new byte[1024];
-            for ( ;; )
+            for (;;)
             {
-                int r = in.read( buf );
+                int r = in.read(buf);
 
-                if ( r == -1 )
+                if (r == -1)
                     break;
 
-                fos.write( buf, 0, r );
+                fos.write(buf, 0, r);
             }
 
             fos.flush();
@@ -679,101 +678,98 @@
             {
                 fos.close();
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                SigilCore.error( "Failed to close stream", e );
+                SigilCore.error("Failed to close stream", e);
             }
         }
     }
 
-
-    private static File createEmptyDir( IPath cache )
+    private static File createEmptyDir(IPath cache)
     {
         File dir = cache.toFile();
-        if ( dir.exists() )
+        if (dir.exists())
         {
-            deleteAll( dir );
+            deleteAll(dir);
         }
 
         dir.mkdirs();
         return dir;
     }
 
-
-    private static void deleteAll( File file )
+    private static void deleteAll(File file)
     {
         File[] sub = file.listFiles();
-        if ( sub != null )
+        if (sub != null)
         {
-            for ( File f : sub )
+            for (File f : sub)
             {
-                deleteAll( f );
+                deleteAll(f);
             }
         }
         file.delete();
     }
 
-
-    private static IAccessRule[] buildAccessRules( ISigilProjectModel project, ISigilBundle bundle,
-        Set<ISigilBundle> all, List<IModelElement> requirements ) throws JavaModelException
+    private static IAccessRule[] buildAccessRules(ISigilProjectModel project,
+        ISigilBundle bundle, Set<ISigilBundle> all, List<IModelElement> requirements)
+        throws JavaModelException
     {
         ArrayList<IAccessRule> rules = new ArrayList<IAccessRule>();
 
-        for ( IModelElement e : requirements )
+        for (IModelElement e : requirements)
         {
-            if ( e instanceof IRequiredBundle )
+            if (e instanceof IRequiredBundle)
             {
                 IRequiredBundle host = project.getBundle().getBundleInfo().getFragmentHost();
-                if ( host != null )
+                if (host != null)
                 {
-                    if ( host.equals( e ) )
+                    if (host.equals(e))
                     {
-                        return new IAccessRule[]
-                            { ALLOW_ALL_RULE };
+                        return new IAccessRule[] { ALLOW_ALL_RULE };
                     }
                     else
                     {
-                        return buildExportRules( bundle, all, requirements );
+                        return buildExportRules(bundle, all, requirements);
                     }
                 }
                 else
                 {
-                    return buildExportRules( bundle, all, requirements );
+                    return buildExportRules(bundle, all, requirements);
                 }
             }
-            else if ( e instanceof IPackageImport )
+            else if (e instanceof IPackageImport)
             {
-                IPackageImport pi = ( IPackageImport ) e;
+                IPackageImport pi = (IPackageImport) e;
                 String pckg = pi.getPackageName();
                 HashSet<String> pckgs = new HashSet<String>();
-                pckgs.add( pckg );
+                pckgs.add(pckg);
                 //findIndirectReferences(pckgs, pckg, project.getJavaModel(), project.getJavaModel());
 
-                for ( String p : pckgs )
+                for (String p : pckgs)
                 {
-                    rules.add( newPackageAccess( p ) );
+                    rules.add(newPackageAccess(p));
                 }
             }
         }
 
-        rules.add( DENY_RULE );
+        rules.add(DENY_RULE);
 
-        return rules.toArray( new IAccessRule[rules.size()] );
+        return rules.toArray(new IAccessRule[rules.size()]);
     }
-    
-    private static IAccessRule[] buildExportRules( ISigilBundle bundle, Set<ISigilBundle> all,
-        List<IModelElement> requirements )
+
+    private static IAccessRule[] buildExportRules(ISigilBundle bundle,
+        Set<ISigilBundle> all, List<IModelElement> requirements)
     {
-        Set<IPackageExport> ex = mergeExports( bundle, all, requirements );
+        Set<IPackageExport> ex = mergeExports(bundle, all, requirements);
 
         IAccessRule[] rules = new IAccessRule[ex.size() + 1];
 
         Iterator<IPackageExport> iter = ex.iterator();
-        for ( int i = 0; i < rules.length - 1; i++ )
+        for (int i = 0; i < rules.length - 1; i++)
         {
             IPackageExport p = iter.next();
-            rules[i] = JavaCore.newAccessRule( new Path( p.getPackageName().replace( '.', '/' ) ).append( "*" ),
-                IAccessRule.K_ACCESSIBLE );
+            rules[i] = JavaCore.newAccessRule(new Path(p.getPackageName().replace('.',
+                '/')).append("*"), IAccessRule.K_ACCESSIBLE);
         }
 
         rules[rules.length - 1] = DENY_RULE;
@@ -781,224 +777,218 @@
         return rules;
     }
 
-
-    private static Set<IPackageExport> mergeExports( ISigilBundle bundle, Set<ISigilBundle> all,
-        List<IModelElement> requirements )
+    private static Set<IPackageExport> mergeExports(ISigilBundle bundle,
+        Set<ISigilBundle> all, List<IModelElement> requirements)
     {
         IBundleModelElement headers = bundle.getBundleInfo();
         // FIXME treeset as PackageExport does not implement equals/hashCode
-        TreeSet<IPackageExport> exports = new TreeSet<IPackageExport>( headers.getExports() );
+        TreeSet<IPackageExport> exports = new TreeSet<IPackageExport>(
+            headers.getExports());
         IRequiredBundle host = headers.getFragmentHost();
-        if ( host != null )
+        if (host != null)
         {
-            for ( ISigilBundle b : all )
+            for (ISigilBundle b : all)
             {
-                if ( host.accepts( b.getBundleCapability() ) )
+                if (host.accepts(b.getBundleCapability()))
                 {
-                    exports.addAll( b.getBundleInfo().getExports() );
+                    exports.addAll(b.getBundleInfo().getExports());
                     break;
                 }
             }
         }
         return exports;
-    }    
-
+    }
 
     /*
      * Searches for C (and D, E, etc) in case:
      * A extends B extends C where A, B and C are in different packages and A is in this bundle
      * and B and C are in one or more external bundles
      */
-    private static void findIndirectReferences( Set<String> indirect, String pckg, IParent parent, IJavaProject p )
-        throws JavaModelException
+    private static void findIndirectReferences(Set<String> indirect, String pckg,
+        IParent parent, IJavaProject p) throws JavaModelException
     {
-        for ( IJavaElement e : parent.getChildren() )
+        for (IJavaElement e : parent.getChildren())
         {
             boolean skip = false;
-            switch ( e.getElementType() )
+            switch (e.getElementType())
             {
                 case IJavaElement.PACKAGE_FRAGMENT_ROOT:
-                    IPackageFragmentRoot rt = ( IPackageFragmentRoot ) e;
+                    IPackageFragmentRoot rt = (IPackageFragmentRoot) e;
                     IClasspathEntry ce = rt.getRawClasspathEntry();
                     IPath path = ce.getPath();
-                    skip = "org.eclipse.jdt.launching.JRE_CONTAINER".equals( path.toString() );
+                    skip = "org.eclipse.jdt.launching.JRE_CONTAINER".equals(path.toString());
                     break;
                 case IJavaElement.CLASS_FILE:
-                    IClassFile cf = ( IClassFile ) e;
-                    if ( cf.getElementName().startsWith( pckg ) )
+                    IClassFile cf = (IClassFile) e;
+                    if (cf.getElementName().startsWith(pckg))
                     {
-                        findIndirectReferences( indirect, findPackage( cf.getType().getSuperclassName() ), p, p );
+                        findIndirectReferences(indirect,
+                            findPackage(cf.getType().getSuperclassName()), p, p);
                     }
                     break;
                 case IJavaElement.COMPILATION_UNIT:
-                    ICompilationUnit cu = ( ICompilationUnit ) e;
+                    ICompilationUnit cu = (ICompilationUnit) e;
                     break;
             }
 
-            if ( !skip && e instanceof IParent )
+            if (!skip && e instanceof IParent)
             {
-                IParent newParent = ( IParent ) e;
-                findIndirectReferences( indirect, pckg, newParent, p );
+                IParent newParent = (IParent) e;
+                findIndirectReferences(indirect, pckg, newParent, p);
             }
         }
     }
 
-
-    private static IAccessRule newPackageAccess( String packageName )
+    private static IAccessRule newPackageAccess(String packageName)
     {
-        return JavaCore.newAccessRule( new Path( packageName.replace( '.', '/' ) ).append( "*" ),
-            IAccessRule.K_ACCESSIBLE );
+        return JavaCore.newAccessRule(
+            new Path(packageName.replace('.', '/')).append("*"), IAccessRule.K_ACCESSIBLE);
     }
 
-
-    private static Set<String> findJavaImports( ISigilProjectModel project, IProgressMonitor monitor )
+    private static Set<String> findJavaImports(ISigilProjectModel project,
+        IProgressMonitor monitor)
     {
         Set<String> imports = new HashSet<String>();
 
-        findJavaModelImports( project, imports, monitor );
-        findTextImports( project, imports, monitor );
+        findJavaModelImports(project, imports, monitor);
+        findTextImports(project, imports, monitor);
 
         return imports;
     }
 
-
-    private static void findTextImports( ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor )
+    private static void findTextImports(ISigilProjectModel project, Set<String> imports,
+        IProgressMonitor monitor)
     {
         IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
-        IContentType txt = contentTypeManager.getContentType( "org.eclipse.core.runtime.text" );
-        for ( Resource p : project.getBundle().getSourcePaths() )
+        IContentType txt = contentTypeManager.getContentType("org.eclipse.core.runtime.text");
+        for (Resource p : project.getBundle().getSourcePaths())
         {
-            IFile f = project.getProject().getFile( p.getLocalFile() );
-            if ( f.exists() )
+            IFile f = project.getProject().getFile(p.getLocalFile());
+            if (f.exists())
             {
                 try
                 {
                     IContentDescription desc = f.getContentDescription();
-                    if ( desc != null )
+                    if (desc != null)
                     {
                         IContentType type = desc.getContentType();
-                        if ( type != null )
+                        if (type != null)
                         {
-                            if ( type.isKindOf( txt ) )
+                            if (type.isKindOf(txt))
                             {
-                                parseText( f, imports );
+                                parseText(f, imports);
                             }
                         }
                     }
                 }
-                catch ( CoreException e )
+                catch (CoreException e)
                 {
-                    SigilCore.error( "Failed to parse text file " + f, e );
+                    SigilCore.error("Failed to parse text file " + f, e);
                 }
             }
         }
     }
 
-
-    private static void findJavaModelImports( ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor )
+    private static void findJavaModelImports(ISigilProjectModel project,
+        Set<String> imports, IProgressMonitor monitor)
     {
         try
         {
-            for ( IPackageFragment root : project.getJavaModel().getPackageFragments() )
+            for (IPackageFragment root : project.getJavaModel().getPackageFragments())
             {
-                IPackageFragmentRoot rt = ( IPackageFragmentRoot ) root
-                    .getAncestor( IJavaElement.PACKAGE_FRAGMENT_ROOT );
+                IPackageFragmentRoot rt = (IPackageFragmentRoot) root.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
 
-                if ( isInClassPath( project, rt ) )
+                if (isInClassPath(project, rt))
                 {
-                    for ( ICompilationUnit cu : root.getCompilationUnits() )
+                    for (ICompilationUnit cu : root.getCompilationUnits())
                     {
-                        scanImports( cu, imports );
+                        scanImports(cu, imports);
                     }
 
-                    for ( IClassFile cf : root.getClassFiles() )
+                    for (IClassFile cf : root.getClassFiles())
                     {
-                        scanImports( cf, imports );
+                        scanImports(cf, imports);
                     }
                 }
             }
         }
-        catch ( JavaModelException e )
+        catch (JavaModelException e)
         {
-            SigilCore.error( "Failed to parse java model", e );
+            SigilCore.error("Failed to parse java model", e);
         }
     }
 
     // matches word.word.word.word.Word
-    private static final Pattern JAVA_CLASS_PATTERN = Pattern.compile( "((\\w*\\.\\w*)+?)\\.[A-Z]\\w*" );
+    private static final Pattern JAVA_CLASS_PATTERN = Pattern.compile("((\\w*\\.\\w*)+?)\\.[A-Z]\\w*");
 
-
-    private static void parseText( IFile f, Set<String> imports ) throws CoreException
+    private static void parseText(IFile f, Set<String> imports) throws CoreException
     {
-        for ( String result : Grep.grep( JAVA_CLASS_PATTERN, f ) )
+        for (String result : Grep.grep(JAVA_CLASS_PATTERN, f))
         {
-            findImport( result, imports );
+            findImport(result, imports);
         }
     }
 
+    private static boolean isInClassPath(ISigilProjectModel project,
+        IPackageFragmentRoot rt) throws JavaModelException
+    {
+        String path = encode(project, rt.getRawClasspathEntry());
+        return project.getBundle().getClasspathEntrys().contains(path);
+    }
 
-    private static boolean isInClassPath( ISigilProjectModel project, IPackageFragmentRoot rt )
+    private static String encode(ISigilProjectModel project, IClasspathEntry cp)
+    {
+        return project.getJavaModel().encodeClasspathEntry(cp).trim();
+    }
+
+    private static void scanImports(IParent parent, Set<String> imports)
         throws JavaModelException
     {
-        String path = encode( project, rt.getRawClasspathEntry() );
-        return project.getBundle().getClasspathEntrys().contains( path );
-    }
-
-
-    private static String encode( ISigilProjectModel project, IClasspathEntry cp )
-    {
-        return project.getJavaModel().encodeClasspathEntry( cp ).trim();
-    }
-
-
-    private static void scanImports( IParent parent, Set<String> imports ) throws JavaModelException
-    {
-        for ( IJavaElement e : parent.getChildren() )
+        for (IJavaElement e : parent.getChildren())
         {
-            switch ( e.getElementType() )
+            switch (e.getElementType())
             {
                 case IJavaElement.TYPE:
-                    handleType( ( IType ) e, imports );
+                    handleType((IType) e, imports);
                     break;
                 case IJavaElement.IMPORT_DECLARATION:
-                    handleImport( ( IImportDeclaration ) e, imports );
+                    handleImport((IImportDeclaration) e, imports);
                     break;
                 case IJavaElement.FIELD:
-                    handleField( ( IField ) e, imports );
+                    handleField((IField) e, imports);
                     break;
                 case IJavaElement.LOCAL_VARIABLE:
-                    handleLocalVariable( ( ILocalVariable ) e, imports );
+                    handleLocalVariable((ILocalVariable) e, imports);
                     break;
                 case IJavaElement.ANNOTATION:
-                    handleAnnotation( ( IAnnotation ) e, imports );
+                    handleAnnotation((IAnnotation) e, imports);
                     break;
                 case IJavaElement.METHOD:
-                    handleMethod( ( IMethod ) e, imports );
+                    handleMethod((IMethod) e, imports);
                     break;
                 default:
                     // no action
                     break;
             }
 
-            if ( e instanceof IParent )
+            if (e instanceof IParent)
             {
-                scanImports( ( IParent ) e, imports );
+                scanImports((IParent) e, imports);
             }
         }
     }
 
-
-    private static void handleType( IType e, Set<String> imports ) throws JavaModelException
+    private static void handleType(IType e, Set<String> imports)
+        throws JavaModelException
     {
-        findImportFromType( e.getSuperclassTypeSignature(), imports );
-        for ( String sig : e.getSuperInterfaceTypeSignatures() )
+        findImportFromType(e.getSuperclassTypeSignature(), imports);
+        for (String sig : e.getSuperInterfaceTypeSignatures())
         {
-            findImportFromType( sig, imports );
+            findImportFromType(sig, imports);
         }
         //findImportsForSuperTypes(e, imports);
     }
 
-
     /*private static void findImportsForSuperTypes(IType e, Set<String> imports) throws JavaModelException {
     	IJavaProject project = (IJavaProject) e.getAncestor(IJavaModel.JAVA_PROJECT);
     	LinkedList<String> types = new LinkedList<String>();
@@ -1026,125 +1016,114 @@
     	}
     } */
 
-    private static void handleMethod( IMethod e, Set<String> imports ) throws JavaModelException
+    private static void handleMethod(IMethod e, Set<String> imports)
+        throws JavaModelException
     {
-        findImportFromType( e.getReturnType(), imports );
+        findImportFromType(e.getReturnType(), imports);
 
-        for ( String param : e.getParameterTypes() )
+        for (String param : e.getParameterTypes())
         {
-            findImportFromType( param, imports );
+            findImportFromType(param, imports);
         }
 
-        for ( String ex : e.getExceptionTypes() )
+        for (String ex : e.getExceptionTypes())
         {
-            findImportFromType( ex, imports );
+            findImportFromType(ex, imports);
         }
     }
 
-
-    private static void handleAnnotation( IAnnotation e, Set<String> imports )
+    private static void handleAnnotation(IAnnotation e, Set<String> imports)
     {
-        findImport( e.getElementName(), imports );
+        findImport(e.getElementName(), imports);
     }
 
-
-    private static void handleLocalVariable( ILocalVariable e, Set<String> imports )
+    private static void handleLocalVariable(ILocalVariable e, Set<String> imports)
     {
-        findImportFromType( e.getTypeSignature(), imports );
+        findImportFromType(e.getTypeSignature(), imports);
     }
 
-
-    private static void handleField( IField e, Set<String> imports ) throws IllegalArgumentException,
-        JavaModelException
+    private static void handleField(IField e, Set<String> imports)
+        throws IllegalArgumentException, JavaModelException
     {
-        findImportFromType( Signature.getElementType( e.getTypeSignature() ), imports );
+        findImportFromType(Signature.getElementType(e.getTypeSignature()), imports);
     }
 
-
-    private static void handleImport( IImportDeclaration id, Set<String> imports )
+    private static void handleImport(IImportDeclaration id, Set<String> imports)
     {
-        findImport( id.getElementName(), imports );
+        findImport(id.getElementName(), imports);
     }
 
-
-    private static void findImportFromType( String type, Set<String> imports )
+    private static void findImportFromType(String type, Set<String> imports)
     {
-        String element = decodeSignature( type );
-        findImport( element, imports );
+        String element = decodeSignature(type);
+        findImport(element, imports);
     }
 
-
-    private static String decodeSignature( String type )
+    private static String decodeSignature(String type)
     {
-        return decodeSignature( type, false );
+        return decodeSignature(type, false);
     }
 
-
-    private static String decodeSignature( String type, boolean resolve )
+    private static String decodeSignature(String type, boolean resolve)
     {
-        if ( type == null )
+        if (type == null)
         {
             return null;
         }
 
-        if ( type.length() > 0 )
+        if (type.length() > 0)
         {
-            switch ( type.charAt( 0 ) )
+            switch (type.charAt(0))
             {
                 case Signature.C_ARRAY:
-                    return decodeSignature( type.substring( 1 ) );
+                    return decodeSignature(type.substring(1));
                 case Signature.C_UNRESOLVED:
-                    return resolve ? resolve( type.substring( 1, type.length() - 1 ) ) : null;
+                    return resolve ? resolve(type.substring(1, type.length() - 1)) : null;
                 case Signature.C_RESOLVED:
-                    return type.substring( 1 );
+                    return type.substring(1);
             }
         }
         return type;
     }
 
-
-    private static String resolve( String substring )
+    private static String resolve(String substring)
     {
         // TODO Auto-generated method stub
         return null;
     }
 
-
-    private static void findImport( String clazz, Set<String> imports )
+    private static void findImport(String clazz, Set<String> imports)
     {
-        String packageName = findPackage( clazz );
-        if ( packageName != null )
+        String packageName = findPackage(clazz);
+        if (packageName != null)
         {
-            imports.add( packageName );
+            imports.add(packageName);
         }
     }
 
-
-    private static String findPackage( String clazz )
+    private static String findPackage(String clazz)
     {
-        if ( clazz == null )
+        if (clazz == null)
             return null;
-        int pos = clazz.lastIndexOf( '.' );
-        return pos == -1 ? null : clazz.substring( 0, pos );
+        int pos = clazz.lastIndexOf('.');
+        return pos == -1 ? null : clazz.substring(0, pos);
     }
 
-
-    private static String findClass( String clazz )
+    private static String findClass(String clazz)
     {
-        if ( clazz == null )
+        if (clazz == null)
             return null;
-        int pos = clazz.lastIndexOf( '.' );
-        return pos == -1 ? null : clazz.substring( pos + 1 );
+        int pos = clazz.lastIndexOf('.');
+        return pos == -1 ? null : clazz.substring(pos + 1);
     }
 
-
-    private static IPackageImport select( Collection<IPackageExport> proposals )
+    private static IPackageImport select(Collection<IPackageExport> proposals)
     {
         IPackageExport pe = null;
 
-        for ( IPackageExport check : proposals )
+        for (IPackageExport check : proposals)
         {
-            if ( pe == null || check.getVersion().compareTo( pe.getVersion() ) > 0 )
+            if (pe == null || check.getVersion().compareTo(pe.getVersion()) > 0)
             {
                 pe = check;
             }
@@ -1155,56 +1134,55 @@
         Version version = pe.getVersion();
         VersionRange versions = ModelHelper.getDefaultRange(version);
 
-        IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
-        pi.setPackageName( packageName );
-        pi.setVersions( versions );
+        IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+            IPackageImport.class);
+        pi.setPackageName(packageName);
+        pi.setVersions(versions);
 
         return pi;
     }
 
-
-    public static Iterable<IJavaElement> findTypes( IParent parent, int... type ) throws JavaModelException
+    public static Iterable<IJavaElement> findTypes(IParent parent, int... type)
+        throws JavaModelException
     {
         LinkedList<IJavaElement> found = new LinkedList<IJavaElement>();
-        scanForElement( parent, type, found, false );
+        scanForElement(parent, type, found, false);
         return found;
     }
 
-
-    public static IJavaElement findType( IParent parent, int... type ) throws JavaModelException
+    public static IJavaElement findType(IParent parent, int... type)
+        throws JavaModelException
     {
         LinkedList<IJavaElement> found = new LinkedList<IJavaElement>();
-        scanForElement( parent, type, found, true );
+        scanForElement(parent, type, found, true);
         return found.isEmpty() ? null : found.getFirst();
     }
 
-
-    private static void scanForElement( IParent parent, int[] type, List<IJavaElement> roots, boolean thereCanBeOnlyOne )
-        throws JavaModelException
+    private static void scanForElement(IParent parent, int[] type,
+        List<IJavaElement> roots, boolean thereCanBeOnlyOne) throws JavaModelException
     {
-        for ( IJavaElement e : parent.getChildren() )
+        for (IJavaElement e : parent.getChildren())
         {
-            if ( isType( type, e ) )
+            if (isType(type, e))
             {
-                roots.add( e );
-                if ( thereCanBeOnlyOne )
+                roots.add(e);
+                if (thereCanBeOnlyOne)
                 {
                     break;
                 }
             }
-            else if ( e instanceof IParent )
+            else if (e instanceof IParent)
             {
-                scanForElement( ( IParent ) e, type, roots, thereCanBeOnlyOne );
+                scanForElement((IParent) e, type, roots, thereCanBeOnlyOne);
             }
         }
     }
 
-
-    private static boolean isType( int[] type, IJavaElement e )
+    private static boolean isType(int[] type, IJavaElement e)
     {
-        for ( int i : type )
+        for (int i : type)
         {
-            if ( i == e.getElementType() )
+            if (i == e.getElementType())
             {
                 return true;
             }
@@ -1212,26 +1190,26 @@
         return false;
     }
 
-
-    public static boolean isAssignableTo( String ifaceOrParentClass, IType type ) throws JavaModelException
+    public static boolean isAssignableTo(String ifaceOrParentClass, IType type)
+        throws JavaModelException
     {
-        if ( ifaceOrParentClass == null )
+        if (ifaceOrParentClass == null)
             return true;
 
-        ITypeHierarchy h = type.newSupertypeHierarchy( null );
+        ITypeHierarchy h = type.newSupertypeHierarchy(null);
 
-        for ( IType superType : h.getAllClasses() )
+        for (IType superType : h.getAllClasses())
         {
             String name = superType.getFullyQualifiedName();
-            if ( name.equals( ifaceOrParentClass ) )
+            if (name.equals(ifaceOrParentClass))
             {
                 return true;
             }
         }
-        for ( IType ifaceType : h.getAllInterfaces() )
+        for (IType ifaceType : h.getAllInterfaces())
         {
             String name = ifaceType.getFullyQualifiedName();
-            if ( name.equals( ifaceOrParentClass ) )
+            if (name.equals(ifaceOrParentClass))
             {
                 return true;
             }
@@ -1240,61 +1218,62 @@
         return false;
     }
 
-
-    private static IType findType( ITypeRoot root ) throws JavaModelException
+    private static IType findType(ITypeRoot root) throws JavaModelException
     {
         // TODO Auto-generated method stub
-        for ( IJavaElement child : root.getChildren() )
+        for (IJavaElement child : root.getChildren())
         {
-            if ( child.getElementType() == IJavaElement.TYPE )
+            if (child.getElementType() == IJavaElement.TYPE)
             {
-                return ( IType ) child;
+                return (IType) child;
             }
         }
 
-        throw new JavaModelException( new IllegalStateException( "Missing type for " + root ), IStatus.ERROR );
+        throw new JavaModelException(
+            new IllegalStateException("Missing type for " + root), IStatus.ERROR);
     }
 
-
-    public static Set<String> findLocalPackageDependencies(
-        ISigilProjectModel project, String packageName, IProgressMonitor monitor) throws JavaModelException
+    public static Set<String> findLocalPackageDependencies(ISigilProjectModel project,
+        String packageName, IProgressMonitor monitor) throws JavaModelException
     {
-        Set<String> imports = findJavaImports( project, monitor );
+        Set<String> imports = findJavaImports(project, monitor);
         imports.remove(packageName);
         return imports;
     }
 
-
-    public static Set<String> findLocalPackageUsers(
-        ISigilProjectModel project, String packageName, IProgressMonitor monitor) throws JavaModelException
+    public static Set<String> findLocalPackageUsers(ISigilProjectModel project,
+        String packageName, IProgressMonitor monitor) throws JavaModelException
     {
         Set<String> imports = new HashSet<String>();
         Set<String> check = new HashSet<String>();
-        for ( IPackageFragment root : project.getJavaModel().getPackageFragments() )
+        for (IPackageFragment root : project.getJavaModel().getPackageFragments())
         {
-            IPackageFragmentRoot rt = ( IPackageFragmentRoot ) root
-                .getAncestor( IJavaElement.PACKAGE_FRAGMENT_ROOT );
+            IPackageFragmentRoot rt = (IPackageFragmentRoot) root.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
 
-            if ( isInClassPath( project, rt ) )
+            if (isInClassPath(project, rt))
             {
-                for ( ICompilationUnit cu : root.getCompilationUnits() )
+                for (ICompilationUnit cu : root.getCompilationUnits())
                 {
                     IPackageFragment pack = (IPackageFragment) cu.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
-                    if ( !pack.getElementName().equals(packageName)) {
-                        scanImports( cu, check );
-                        if (check.contains(packageName)) {
+                    if (!pack.getElementName().equals(packageName))
+                    {
+                        scanImports(cu, check);
+                        if (check.contains(packageName))
+                        {
                             imports.add(pack.getElementName());
                         }
                     }
                     check.clear();
                 }
 
-                for ( IClassFile cf : root.getClassFiles() )
+                for (IClassFile cf : root.getClassFiles())
                 {
                     IPackageFragment pack = (IPackageFragment) cf.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
-                    if ( !pack.getElementName().equals(packageName)) {
-                        scanImports( cf, check );
-                        if (check.contains(packageName)) {
+                    if (!pack.getElementName().equals(packageName))
+                    {
+                        scanImports(cf, check);
+                        if (check.contains(packageName))
+                        {
                             imports.add(pack.getElementName());
                         }
                     }
@@ -1302,7 +1281,7 @@
                 }
             }
         }
-        
+
         return imports;
     }
 }
\ No newline at end of file
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java
index 67ffd43..5a4ca70 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.model.util;
 
-
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
@@ -39,75 +38,77 @@
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.osgi.framework.Version;
 
-
 public class ModelHelper
 {
-    public static List<IModelElement> findUsers( IModelElement e )
+    public static List<IModelElement> findUsers(IModelElement e)
     {
         LinkedList<IModelElement> users = new LinkedList<IModelElement>();
 
-        findUsers( e, users );
+        findUsers(e, users);
 
         return users;
     }
 
-
-    private static void findUsers( IModelElement e, final LinkedList<IModelElement> users )
+    private static void findUsers(IModelElement e, final LinkedList<IModelElement> users)
     {
-        if ( e instanceof ICapabilityModelElement )
+        if (e instanceof ICapabilityModelElement)
         {
-            final ICapabilityModelElement cap = ( ICapabilityModelElement ) e;
-            SigilCore.getGlobalRepositoryManager().visit( new IModelWalker()
+            final ICapabilityModelElement cap = (ICapabilityModelElement) e;
+            SigilCore.getGlobalRepositoryManager().visit(new IModelWalker()
             {
-                public boolean visit( IModelElement element )
+                public boolean visit(IModelElement element)
                 {
-                    if ( element instanceof IRequirementModelElement )
+                    if (element instanceof IRequirementModelElement)
                     {
-                        IRequirementModelElement req = ( IRequirementModelElement ) element;
-                        if ( req.accepts( cap ) )
+                        IRequirementModelElement req = (IRequirementModelElement) element;
+                        if (req.accepts(cap))
                         {
-                            users.add( req );
+                            users.add(req);
                         }
                         return false;
                     }
 
                     return true;
                 }
-            } );
+            });
         }
-        
-        if ( e instanceof ICompoundModelElement )
+
+        if (e instanceof ICompoundModelElement)
         {
-            ICompoundModelElement c = ( ICompoundModelElement ) e;
+            ICompoundModelElement c = (ICompoundModelElement) e;
             IModelElement[] ch = c.children();
-            for ( IModelElement ee : ch )
+            for (IModelElement ee : ch)
             {
-                findUsers( ee, users );
+                findUsers(ee, users);
             }
         }
     }
-    
-    public static VersionRange getDefaultRange(Version version) {
-        IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
-        
-        VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf( store
-            .getString( SigilCore.DEFAULT_VERSION_LOWER_BOUND ) );
-        VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf( store
-            .getString( SigilCore.DEFAULT_VERSION_UPPER_BOUND ) );
 
-        VersionRange selectedVersions = VersionRange.newInstance( version, lowerBoundRule, upperBoundRule );
+    public static VersionRange getDefaultRange(Version version)
+    {
+        IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
+
+        VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND));
+        VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND));
+
+        VersionRange selectedVersions = VersionRange.newInstance(version, lowerBoundRule,
+            upperBoundRule);
         return selectedVersions;
     }
-    
-    public static IPackageExport findExport(ISigilProjectModel sigil, final String packageName) {
+
+    public static IPackageExport findExport(ISigilProjectModel sigil,
+        final String packageName)
+    {
         final ArrayList<IPackageExport> found = new ArrayList<IPackageExport>(1);
         sigil.visit(new IModelWalker()
-        {            
+        {
             public boolean visit(IModelElement element)
             {
-                if (element instanceof IPackageExport) {
+                if (element instanceof IPackageExport)
+                {
                     IPackageExport pe = (IPackageExport) element;
-                    if (pe.getPackageName().equals(packageName)) {
+                    if (pe.getPackageName().equals(packageName))
+                    {
                         found.add(pe);
                     }
                 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java
index 23d67c1..abb9d79 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.model.util;
 
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -35,27 +34,25 @@
 import org.eclipse.core.runtime.Platform;
 import org.osgi.framework.Bundle;
 
-
 public class ProfileManager
 {
-    private static final Pattern[] BOOT_DELEGATION_PATTERNS = new Pattern[]
-        { GlobCompiler.compile( "org.ietf.jgss" ), GlobCompiler.compile( "org.omg.*" ),
-            GlobCompiler.compile( "org.w3c.*" ), GlobCompiler.compile( "org.xml.*" ), GlobCompiler.compile( "sun.*" ),
-            GlobCompiler.compile( "com.sun.*" ), };
+    private static final Pattern[] BOOT_DELEGATION_PATTERNS = new Pattern[] {
+            GlobCompiler.compile("org.ietf.jgss"), GlobCompiler.compile("org.omg.*"),
+            GlobCompiler.compile("org.w3c.*"), GlobCompiler.compile("org.xml.*"),
+            GlobCompiler.compile("sun.*"), GlobCompiler.compile("com.sun.*"), };
 
     private static HashMap<String, Properties> profiles;
 
-
-    public static boolean isBootDelegate( ISigilProjectModel project, String packageName )
+    public static boolean isBootDelegate(ISigilProjectModel project, String packageName)
     {
-        if ( packageName.startsWith( "java." ) )
+        if (packageName.startsWith("java."))
         {
             return true;
         }
 
-        for ( Pattern p : BOOT_DELEGATION_PATTERNS )
+        for (Pattern p : BOOT_DELEGATION_PATTERNS)
         {
-            if ( p.matcher( packageName ).matches() )
+            if (p.matcher(packageName).matches())
             {
                 return true;
             }
@@ -63,60 +60,59 @@
         return false;
     }
 
-
-    public static Properties findProfileForVersion( String javaVersion )
+    public static Properties findProfileForVersion(String javaVersion)
     {
         Map<String, Properties> profiles = loadProfiles();
 
-        if ( "1.5.0".equals( javaVersion ) )
+        if ("1.5.0".equals(javaVersion))
         {
-            return profiles.get( "J2SE-1.5" );
+            return profiles.get("J2SE-1.5");
         }
-        else if ( "1.6.0".equals( javaVersion ) )
+        else if ("1.6.0".equals(javaVersion))
         {
-            return profiles.get( "J2SE-1.6" );
+            return profiles.get("J2SE-1.6");
         }
 
         return null;
     }
 
-
     private synchronized static Map<String, Properties> loadProfiles()
     {
-        if ( profiles == null )
+        if (profiles == null)
         {
             profiles = new HashMap<String, Properties>();
 
-            Bundle b = Platform.getBundle( "org.eclipse.osgi" );
+            Bundle b = Platform.getBundle("org.eclipse.osgi");
 
-            for ( String profile : loadProfiles( b ) )
+            for (String profile : loadProfiles(b))
             {
-                if ( profile.trim().length() > 0 )
+                if (profile.trim().length() > 0)
                 {
-                    URL url = findURL( profile, b );
-                    if ( url != null )
+                    URL url = findURL(profile, b);
+                    if (url != null)
                     {
                         try
                         {
-                            Properties p = loadProperties( url );
-                            String name = p.getProperty( "osgi.java.profile.name" );
-                            if ( name != null )
+                            Properties p = loadProperties(url);
+                            String name = p.getProperty("osgi.java.profile.name");
+                            if (name != null)
                             {
-                                profiles.put( name, p );
+                                profiles.put(name, p);
                             }
                             else
                             {
-                                SigilCore.error( "Invalid profile definition, no name specified: " + url );
+                                SigilCore.error("Invalid profile definition, no name specified: "
+                                    + url);
                             }
                         }
-                        catch ( IOException e )
+                        catch (IOException e)
                         {
-                            SigilCore.error( "Failed to load java profile", e );
+                            SigilCore.error("Failed to load java profile", e);
                         }
                     }
                     else
                     {
-                        SigilCore.error( "Unknown profile **" + profile + "**" );
+                        SigilCore.error("Unknown profile **" + profile + "**");
                     }
                 }
                 // else ignore empty values
@@ -125,45 +121,40 @@
         return profiles;
     }
 
-
-    private static String[] loadProfiles( Bundle b )
+    private static String[] loadProfiles(Bundle b)
     {
-        URL url = findURL( "profile.list", b );
+        URL url = findURL("profile.list", b);
 
-        if ( url != null )
+        if (url != null)
         {
             try
             {
-                Properties p = loadProperties( url );
-                String s = p.getProperty( "java.profiles" );
-                return s == null ? new String[]
-                    {} : s.split( "," );
+                Properties p = loadProperties(url);
+                String s = p.getProperty("java.profiles");
+                return s == null ? new String[] {} : s.split(",");
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                SigilCore.error( "Failed to load java profile list", e );
+                SigilCore.error("Failed to load java profile list", e);
             }
         }
         else
         {
-            SigilCore.error( "Failed to find java profile list" );
+            SigilCore.error("Failed to find java profile list");
         }
 
         // fine no properties found
-        return new String[]
-            {};
+        return new String[] {};
     }
 
-
     @SuppressWarnings("unchecked")
-    private static URL findURL( String file, Bundle b )
+    private static URL findURL(String file, Bundle b)
     {
-        Enumeration e = b.findEntries( "/", file, false );
-        return e == null ? null : ( URL ) ( e.hasMoreElements() ? e.nextElement() : null );
+        Enumeration e = b.findEntries("/", file, false);
+        return e == null ? null : (URL) (e.hasMoreElements() ? e.nextElement() : null);
     }
 
-
-    private static Properties loadProperties( URL url ) throws IOException
+    private static Properties loadProperties(URL url) throws IOException
     {
         Properties p = new Properties();
 
@@ -172,17 +163,17 @@
         try
         {
             in = url.openStream();
-            p.load( in );
+            p.load(in);
         }
         finally
         {
-            if ( in != null )
+            if (in != null)
             {
                 try
                 {
                     in.close();
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java
index 603e61e..fb3ef0f 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java
@@ -19,37 +19,31 @@
 
 package org.apache.felix.sigil.eclipse.nature;
 
-
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectNature;
 import org.eclipse.core.runtime.CoreException;
 
-
 public class SigilProjectNature implements IProjectNature
 {
 
     private IProject project;
 
-
     public void configure() throws CoreException
     {
         // TODO configure project builder
 
     }
 
-
     public void deconfigure() throws CoreException
     {
     }
 
-
     public IProject getProject()
     {
         return project;
     }
 
-
-    public void setProject( IProject project )
+    public void setProject(IProject project)
     {
         this.project = project;
     }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java
index e525c41..14e7d57 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.preferences;
 
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -27,7 +26,6 @@
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.text.StrTokenizer;
 
-
 public class PrefsUtils
 {
 
@@ -35,28 +33,26 @@
     {
     }
 
-
-    public static final String arrayToString( String[] array )
+    public static final String arrayToString(String[] array)
     {
         StringBuilder builder = new StringBuilder();
 
-        for ( int i = 0; i < array.length; i++ )
+        for (int i = 0; i < array.length; i++)
         {
-            if ( i > 0 )
-                builder.append( ',' );
-            builder.append( StringEscapeUtils.escapeCsv( array[i] ) );
+            if (i > 0)
+                builder.append(',');
+            builder.append(StringEscapeUtils.escapeCsv(array[i]));
         }
 
         return builder.toString();
     }
 
-
-    public static final String[] stringToArray( String string )
+    public static final String[] stringToArray(String string)
     {
-        StrTokenizer tokenizer = new StrTokenizer( string, ',', '"' );
+        StrTokenizer tokenizer = new StrTokenizer(string, ',', '"');
         String[] array = new String[tokenizer.size()];
 
-        for ( int i = 0; i < array.length; i++ )
+        for (int i = 0; i < array.length; i++)
         {
             array[i] = tokenizer.nextToken();
         }
@@ -64,15 +60,13 @@
         return array;
     }
 
-
-    public static String listToString( List<String> names )
+    public static String listToString(List<String> names)
     {
-        return arrayToString( names.toArray( new String[names.size()] ) );
+        return arrayToString(names.toArray(new String[names.size()]));
     }
 
-
-    public static List<String> stringToList( String string )
+    public static List<String> stringToList(String string)
     {
-        return new ArrayList<String>( Arrays.asList( stringToArray( string ) ) );
+        return new ArrayList<String>(Arrays.asList(stringToArray(string)));
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java
index 4235c54..e904bdc 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.preferences;
 
-
 public enum PromptablePreference
 {
     Always, Prompt, Never
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java
index 22e4271..7dbfc0d 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java
@@ -19,39 +19,42 @@
 
 package org.apache.felix.sigil.eclipse.preferences;
 
-
 import org.apache.felix.sigil.common.osgi.VersionRangeBoundingRule;
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.internal.model.repository.RepositoryConfiguration;
 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
 import org.eclipse.jface.preference.IPreferenceStore;
 
-
 public class SigilPreferencesInitializer extends AbstractPreferenceInitializer
 {
 
-    public static final String[] EXCLUDED_RESOURCES = new String[]
-        { ".project", ".classpath", ".settings" };
-
+    public static final String[] EXCLUDED_RESOURCES = new String[] { ".project",
+            ".classpath", ".settings" };
 
     @Override
     public void initializeDefaultPreferences()
     {
         IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
 
-        store.setDefault( SigilCore.OSGI_INSTALL_CHECK_PREFERENCE, true );
+        store.setDefault(SigilCore.OSGI_INSTALL_CHECK_PREFERENCE, true);
 
-        store.setDefault( SigilCore.DEFAULT_VERSION_LOWER_BOUND, VersionRangeBoundingRule.Micro.name() );
-        store.setDefault( SigilCore.DEFAULT_VERSION_UPPER_BOUND, VersionRangeBoundingRule.Any.name() );
+        store.setDefault(SigilCore.DEFAULT_VERSION_LOWER_BOUND,
+            VersionRangeBoundingRule.Micro.name());
+        store.setDefault(SigilCore.DEFAULT_VERSION_UPPER_BOUND,
+            VersionRangeBoundingRule.Any.name());
 
-        store.setDefault( SigilCore.DEFAULT_EXCLUDED_RESOURCES, PrefsUtils.arrayToString( EXCLUDED_RESOURCES ) );
+        store.setDefault(SigilCore.DEFAULT_EXCLUDED_RESOURCES,
+            PrefsUtils.arrayToString(EXCLUDED_RESOURCES));
 
-        store.setDefault( SigilCore.PREFERENCES_NOASK_OSGI_INSTALL, false );
+        store.setDefault(SigilCore.PREFERENCES_NOASK_OSGI_INSTALL, false);
 
-        store.setDefault( SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT, PromptablePreference.Prompt.name() );
+        store.setDefault(SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT,
+            PromptablePreference.Prompt.name());
 
-        store.setDefault( SigilCore.PREFERENCES_REBUILD_PROJECTS, PromptablePreference.Prompt.name() );
+        store.setDefault(SigilCore.PREFERENCES_REBUILD_PROJECTS,
+            PromptablePreference.Prompt.name());
 
-        store.setDefault( RepositoryConfiguration.REPOSITORY_DEFAULT_SET, "org.apache.felix.sigil.core.workspaceprovider" );
+        store.setDefault(RepositoryConfiguration.REPOSITORY_DEFAULT_SET,
+            "org.apache.felix.sigil.core.workspaceprovider");
     }
 }
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/property/SigilPropertyTester.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/property/SigilPropertyTester.java
index 97f8baf..97caef3 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/property/SigilPropertyTester.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/property/SigilPropertyTester.java
@@ -19,13 +19,11 @@
 
 package org.apache.felix.sigil.eclipse.property;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.eclipse.core.expressions.PropertyTester;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 
-
 public class SigilPropertyTester extends PropertyTester
 {
 
@@ -33,32 +31,31 @@
     {
     }
 
-
-    public boolean test( Object receiver, String property, Object[] args, Object expectedValue )
+    public boolean test(Object receiver, String property, Object[] args,
+        Object expectedValue)
     {
-        IResource resource = ( IResource ) receiver;
-        if ( "isSigilProject".equals( property ) )
+        IResource resource = (IResource) receiver;
+        if ("isSigilProject".equals(property))
         {
-            return expectedValue.equals( isSigilProjectLikeResource( resource ) );
+            return expectedValue.equals(isSigilProjectLikeResource(resource));
         }
         return false;
     }
 
-
     /**
      * @param resource
      * @return
      */
-    private static boolean isSigilProjectLikeResource( IResource resource )
+    private static boolean isSigilProjectLikeResource(IResource resource)
     {
-        if ( resource instanceof IProject )
+        if (resource instanceof IProject)
         {
-            IProject p = ( IProject ) resource;
-            return SigilCore.isSigilProject( p );
+            IProject p = (IProject) resource;
+            return SigilCore.isSigilProject(p);
         }
         else
         {
-            return resource.getName().equals( SigilCore.SIGIL_PROJECT_FILE );
+            return resource.getName().equals(SigilCore.SIGIL_PROJECT_FILE);
         }
     }
 
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/AbstractNewWizardAction.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/AbstractNewWizardAction.java
index be13319..56609de 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/AbstractNewWizardAction.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/AbstractNewWizardAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.cheatsheets.actions;
 
-
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.viewers.ISelection;
@@ -32,7 +31,6 @@
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 
-
 public abstract class AbstractNewWizardAction extends Action
 {
 
@@ -44,31 +42,29 @@
         try
         {
             INewWizard wizard = createWizard();
-            wizard.init( PlatformUI.getWorkbench(), getSelection() );
-            WizardDialog dialog = new WizardDialog( shell, wizard );
+            wizard.init(PlatformUI.getWorkbench(), getSelection());
+            WizardDialog dialog = new WizardDialog(shell, wizard);
             int res = dialog.open();
-            notifyResult( res == Window.OK );
+            notifyResult(res == Window.OK);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
     }
 
-
     protected abstract INewWizard createWizard() throws CoreException;
 
-
     private IStructuredSelection getSelection()
     {
         IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-        if ( window != null )
+        if (window != null)
         {
             ISelection selection = window.getSelectionService().getSelection();
-            if ( selection instanceof IStructuredSelection )
+            if (selection instanceof IStructuredSelection)
             {
-                return ( IStructuredSelection ) selection;
+                return (IStructuredSelection) selection;
             }
         }
         return StructuredSelection.EMPTY;
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/CopyResourceFromPlugin.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/CopyResourceFromPlugin.java
index 6be47b2..14491de 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/CopyResourceFromPlugin.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/CopyResourceFromPlugin.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.cheatsheets.actions;
 
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
@@ -47,7 +46,6 @@
 import org.eclipse.ui.part.FileEditorInput;
 import org.osgi.framework.Bundle;
 
-
 public class CopyResourceFromPlugin extends Action implements ICheatSheetAction
 {
 
@@ -57,10 +55,9 @@
     private String sourcePath;
     private String editorID;
 
-
-    public void run( String[] params, ICheatSheetManager manager )
+    public void run(String[] params, ICheatSheetManager manager)
     {
-        if ( params != null && params.length > 4 )
+        if (params != null && params.length > 4)
         {
             targetProject = params[0];
             targetFolder = params[1];
@@ -72,31 +69,31 @@
         WorkspaceModifyOperation op = new WorkspaceModifyOperation()
         {
             @Override
-            protected void execute( IProgressMonitor monitor ) throws CoreException
+            protected void execute(IProgressMonitor monitor) throws CoreException
             {
                 try
                 {
-                    Bundle b = Platform.getBundle( sourceBundle );
+                    Bundle b = Platform.getBundle(sourceBundle);
 
                     IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-                    IProject project = workspaceRoot.getProject( targetProject );
-                    IPath path = new Path( targetFolder )
-                        .append( sourcePath.substring( sourcePath.lastIndexOf( '/' ) ) );
-                    IFile file = project.getFile( path );
+                    IProject project = workspaceRoot.getProject(targetProject);
+                    IPath path = new Path(targetFolder).append(sourcePath.substring(sourcePath.lastIndexOf('/')));
+                    IFile file = project.getFile(path);
 
-                    if ( !file.exists() )
+                    if (!file.exists())
                     {
-                        mkdirs( ( IFolder ) file.getParent(), monitor );
+                        mkdirs((IFolder) file.getParent(), monitor);
 
-                        InputStream in = FileLocator.openStream( b, new Path( sourcePath ), false );
-                        file.create( in, true, monitor );
+                        InputStream in = FileLocator.openStream(b, new Path(sourcePath),
+                            false);
+                        file.create(in, true, monitor);
                     }
 
                     IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-                    FileEditorInput input = new FileEditorInput( file );
-                    window.getActivePage().openEditor( input, editorID );
+                    FileEditorInput input = new FileEditorInput(file);
+                    window.getActivePage().openEditor(input, editorID);
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
@@ -106,32 +103,32 @@
 
         try
         {
-            new ProgressMonitorDialog( Display.getCurrent().getActiveShell() ).run( false, false, op );
+            new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(false,
+                false, op);
         }
-        catch ( InvocationTargetException e )
+        catch (InvocationTargetException e)
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
-        catch ( InterruptedException e )
+        catch (InterruptedException e)
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
     }
 
-
-    private void mkdirs( IFolder folder, IProgressMonitor monitor ) throws CoreException
+    private void mkdirs(IFolder folder, IProgressMonitor monitor) throws CoreException
     {
         IContainer parent = folder.getParent();
-        if ( !parent.exists() )
+        if (!parent.exists())
         {
-            mkdirs( ( IFolder ) parent, monitor );
+            mkdirs((IFolder) parent, monitor);
         }
 
-        if ( !folder.exists() )
+        if (!folder.exists())
         {
-            folder.create( true, true, monitor );
+            folder.create(true, true, monitor);
         }
 
     }
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/OpenEmptySigilProjectWizardAction.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/OpenEmptySigilProjectWizardAction.java
index 1ee883c..ef869b3 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/OpenEmptySigilProjectWizardAction.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/OpenEmptySigilProjectWizardAction.java
@@ -19,23 +19,20 @@
 
 package org.apache.felix.sigil.eclipse.cheatsheets.actions;
 
-
 import org.apache.felix.sigil.eclipse.ui.wizard.project.SigilProjectWizard;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.cheatsheets.ICheatSheetAction;
 import org.eclipse.ui.cheatsheets.ICheatSheetManager;
 
-
 public class OpenEmptySigilProjectWizardAction extends AbstractNewWizardAction implements ICheatSheetAction
 {
 
     private String name;
 
-
-    public void run( String[] params, ICheatSheetManager manager )
+    public void run(String[] params, ICheatSheetManager manager)
     {
-        if ( params != null && params.length > 0 )
+        if (params != null && params.length > 0)
         {
             name = params[0];
         }
@@ -43,12 +40,11 @@
         run();
     }
 
-
     @Override
     protected INewWizard createWizard() throws CoreException
     {
         SigilProjectWizard wizard = new SigilProjectWizard();
-        wizard.setName( name );
+        wizard.setName(name);
         return wizard;
     }
 }
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ResolveProjectDependencies.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ResolveProjectDependencies.java
index a7ca1cc..cebdfc4 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ResolveProjectDependencies.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ResolveProjectDependencies.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.cheatsheets.actions;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.eclipse.ui.actions.ResolveProjectDependenciesAction;
@@ -31,29 +30,27 @@
 import org.eclipse.ui.cheatsheets.ICheatSheetAction;
 import org.eclipse.ui.cheatsheets.ICheatSheetManager;
 
-
 public class ResolveProjectDependencies extends Action implements ICheatSheetAction
 {
 
     private String targetProject;
 
-
-    public void run( String[] params, ICheatSheetManager manager )
+    public void run(String[] params, ICheatSheetManager manager)
     {
-        if ( params != null && params.length > 3 )
+        if (params != null && params.length > 3)
         {
             targetProject = params[0];
         }
 
         IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-        IProject project = workspaceRoot.getProject( targetProject );
+        IProject project = workspaceRoot.getProject(targetProject);
 
         try
         {
-            ISigilProjectModel sigil = SigilCore.create( project );
-            new ResolveProjectDependenciesAction( sigil, false ).run();
+            ISigilProjectModel sigil = SigilCore.create(project);
+            new ResolveProjectDependenciesAction(sigil, false).run();
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ShowViewAction.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ShowViewAction.java
index 57ebfff..9e9af4a 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ShowViewAction.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ShowViewAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.cheatsheets.actions;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.eclipse.jface.action.Action;
 import org.eclipse.ui.IWorkbenchPage;
@@ -29,23 +28,22 @@
 import org.eclipse.ui.cheatsheets.ICheatSheetAction;
 import org.eclipse.ui.cheatsheets.ICheatSheetManager;
 
-
 public class ShowViewAction extends Action implements ICheatSheetAction
 {
 
-    public void run( String[] params, ICheatSheetManager manager )
+    public void run(String[] params, ICheatSheetManager manager)
     {
-        if ( params != null && params.length > 0 )
+        if (params != null && params.length > 0)
         {
             IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
             IWorkbenchPage page = window.getActivePage();
             try
             {
-                page.showView( params[0] );
+                page.showView(params[0]);
             }
-            catch ( PartInitException e )
+            catch (PartInitException e)
             {
-                SigilCore.error( "Failed to show view", e );
+                SigilCore.error("Failed to show view", e);
             }
         }
 
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/help/Activator.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/help/Activator.java
index 6aea34a..99429cc 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/help/Activator.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/help/Activator.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.help;
 
-
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
-
 /**
  * The activator class controls the plug-in life cycle
  */
@@ -36,7 +34,6 @@
     // The shared instance
     private static Activator plugin;
 
-
     /**
      * The constructor
      */
@@ -44,29 +41,26 @@
     {
     }
 
-
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
      */
-    public void start( BundleContext context ) throws Exception
+    public void start(BundleContext context) throws Exception
     {
-        super.start( context );
+        super.start(context);
         plugin = this;
     }
 
-
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
      */
-    public void stop( BundleContext context ) throws Exception
+    public void stop(BundleContext context) throws Exception
     {
         plugin = null;
-        super.stop( context );
+        super.stop(context);
     }
 
-
     /**
      * Returns the shared instance
      *
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/LaunchHelper.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/LaunchHelper.java
index 289428b..b2deb73 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/LaunchHelper.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/LaunchHelper.java
@@ -34,35 +34,37 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.ILaunchConfiguration;
 
-public class LaunchHelper {
+public class LaunchHelper
+{
 
-	public static IOSGiInstall getInstall(ILaunchConfiguration config) {
-	    return null;
-	}
+    public static IOSGiInstall getInstall(ILaunchConfiguration config)
+    {
+        return null;
+    }
 
-    public static int getRetries( ILaunchConfiguration config )
+    public static int getRetries(ILaunchConfiguration config)
     {
         return 5;
     }
 
-    public static Properties buildClientProps( ILaunchConfiguration config )
+    public static Properties buildClientProps(ILaunchConfiguration config)
     {
         Properties props = new Properties();
-        props.put( Runtime.ADDRESS_PROPERTY, "localhost" );
-        props.put( Runtime.PORT_PROPERTY, "9090" );
+        props.put(Runtime.ADDRESS_PROPERTY, "localhost");
+        props.put(Runtime.PORT_PROPERTY, "9090");
         return props;
     }
 
-    public static String[] getProgramArgs( ILaunchConfiguration config )
+    public static String[] getProgramArgs(ILaunchConfiguration config)
     {
         return new String[] { "-p", "9090", "-a", "localhost", "-c" };
     }
 
-    public static long getBackoff( ILaunchConfiguration config )
+    public static long getBackoff(ILaunchConfiguration config)
     {
         return 1000;
     }
-    
+
     public static URL toURL(String loc) throws MalformedURLException
     {
         URL url = null;
@@ -73,19 +75,23 @@
         catch (MalformedURLException e)
         {
             IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(loc));
-            if ( f.exists() ) {
+            if (f.exists())
+            {
                 url = f.getLocation().toFile().toURL();
             }
-            else {
-                throw new MalformedURLException("Unknown file " + loc );
+            else
+            {
+                throw new MalformedURLException("Unknown file " + loc);
             }
         }
         return url;
     }
 
-    public static BundleForm getBundleForm(ILaunchConfiguration config) throws CoreException
+    public static BundleForm getBundleForm(ILaunchConfiguration config)
+        throws CoreException
     {
-        String loc = config.getAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, (String) null);
+        String loc = config.getAttribute(
+            OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, (String) null);
         try
         {
             URL url = toURL(loc);
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/OSGiLauncher.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/OSGiLauncher.java
index 193ba26..c376444 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/OSGiLauncher.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/OSGiLauncher.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.runtime;
 
-
 import java.io.IOException;
 
 import java.net.ConnectException;
@@ -45,49 +44,48 @@
 import org.eclipse.jdt.launching.IVMRunner;
 import org.eclipse.jdt.launching.VMRunnerConfiguration;
 
-
-public class OSGiLauncher extends AbstractJavaLaunchConfigurationDelegate implements ILaunchConfigurationDelegate,
-    ILaunchConfigurationDelegate2
+public class OSGiLauncher extends AbstractJavaLaunchConfigurationDelegate implements ILaunchConfigurationDelegate, ILaunchConfigurationDelegate2
 {
 
-    public void launch( ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor )
-        throws CoreException
+    public void launch(ILaunchConfiguration config, String mode, ILaunch launch,
+        IProgressMonitor monitor) throws CoreException
     {
-        IOSGiInstall osgi = LaunchHelper.getInstall( config );
+        IOSGiInstall osgi = LaunchHelper.getInstall(config);
 
-        VMRunnerConfiguration vmconfig = new VMRunnerConfiguration( Main.class.getName(), buildClasspath( osgi, config ) );
+        VMRunnerConfiguration vmconfig = new VMRunnerConfiguration(Main.class.getName(),
+            buildClasspath(osgi, config));
 
-        String vm = getVMArguments( config );
-        if ( vm != null && vm.trim().length() > 0 )
-            vmconfig.setVMArguments( vm.split( " " ) );
-                
-        IPath path = getWorkingDirectoryPath( config );
-        vmconfig.setWorkingDirectory( path == null ? null : path.toOSString() );
-        
-        vmconfig.setBootClassPath( getBootpath( config ) );
-        vmconfig.setEnvironment( getEnvironment( config ) );
-        vmconfig.setProgramArguments( LaunchHelper.getProgramArgs( config ) );
+        String vm = getVMArguments(config);
+        if (vm != null && vm.trim().length() > 0)
+            vmconfig.setVMArguments(vm.split(" "));
 
-        IVMInstall install = getVMInstall( config );
+        IPath path = getWorkingDirectoryPath(config);
+        vmconfig.setWorkingDirectory(path == null ? null : path.toOSString());
 
-        IVMRunner runner = install.getVMRunner( mode );
+        vmconfig.setBootClassPath(getBootpath(config));
+        vmconfig.setEnvironment(getEnvironment(config));
+        vmconfig.setProgramArguments(LaunchHelper.getProgramArgs(config));
 
-        setDefaultSourceLocator( launch, config );
+        IVMInstall install = getVMInstall(config);
 
-        SigilCore.log( "VM=" + install.getName() );
-        SigilCore.log( "Main=" + vmconfig.getClassToLaunch() );
-        SigilCore.log( "VMArgs=" + Arrays.asList( vmconfig.getVMArguments() ) );
-        SigilCore.log( "Boot Classpath=" + Arrays.asList( vmconfig.getBootClassPath() ) );
-        SigilCore.log( "Classpath=" + Arrays.asList( vmconfig.getClassPath() ) );
-        SigilCore.log( "Args=" + Arrays.asList( vmconfig.getProgramArguments() ) );
-        SigilCore.log( "Working Dir=" + vmconfig.getWorkingDirectory() );
+        IVMRunner runner = install.getVMRunner(mode);
 
-        runner.run( vmconfig, launch, monitor );
+        setDefaultSourceLocator(launch, config);
 
-        Client client = connect( config );
-        
+        SigilCore.log("VM=" + install.getName());
+        SigilCore.log("Main=" + vmconfig.getClassToLaunch());
+        SigilCore.log("VMArgs=" + Arrays.asList(vmconfig.getVMArguments()));
+        SigilCore.log("Boot Classpath=" + Arrays.asList(vmconfig.getBootClassPath()));
+        SigilCore.log("Classpath=" + Arrays.asList(vmconfig.getClassPath()));
+        SigilCore.log("Args=" + Arrays.asList(vmconfig.getProgramArguments()));
+        SigilCore.log("Working Dir=" + vmconfig.getWorkingDirectory());
+
+        runner.run(vmconfig, launch, monitor);
+
+        Client client = connect(config);
+
         BundleForm form = LaunchHelper.getBundleForm(config);
-        
+
         try
         {
             String name = LaunchHelper.getRepositoryManagerName(config);
@@ -99,96 +97,95 @@
             throw SigilCore.newCoreException("Failed to apply bundle form", e);
         }
 
-        SigilCore.log( "Connected " + client.isConnected() );
+        SigilCore.log("Connected " + client.isConnected());
     }
 
-
-    private Client connect( ILaunchConfiguration config ) throws CoreException
+    private Client connect(ILaunchConfiguration config) throws CoreException
     {
-        Properties props = LaunchHelper.buildClientProps( config );
+        Properties props = LaunchHelper.buildClientProps(config);
 
-        int retry = LaunchHelper.getRetries( config );
+        int retry = LaunchHelper.getRetries(config);
 
         Client client = null;
 
-        for ( int i = 0; i < retry; i++ )
+        for (int i = 0; i < retry; i++)
         {
             client = new Client();
             try
             {
-                client.connect( props );
+                client.connect(props);
                 break;
             }
-            catch ( ConnectException e )
+            catch (ConnectException e)
             {
-                SigilCore.log( "Failed to connect to client: " + e.getMessage() );
+                SigilCore.log("Failed to connect to client: " + e.getMessage());
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                throw SigilCore.newCoreException( "Failed to connect client", e );
+                throw SigilCore.newCoreException("Failed to connect client", e);
             }
 
             try
             {
-                Thread.sleep( LaunchHelper.getBackoff( config ) );
+                Thread.sleep(LaunchHelper.getBackoff(config));
             }
-            catch ( InterruptedException e )
+            catch (InterruptedException e)
             {
-                SigilCore.log( "Interrupted during backoff" );
+                SigilCore.log("Interrupted during backoff");
             }
         }
 
-        if ( client == null )
+        if (client == null)
         {
-            throw SigilCore.newCoreException( "Failed to connect client after retries, check error log for details",
-                null );
+            throw SigilCore.newCoreException(
+                "Failed to connect client after retries, check error log for details",
+                null);
         }
 
         return client;
     }
 
-
-    public String[] getBootpath( ILaunchConfiguration configuration ) throws CoreException
+    public String[] getBootpath(ILaunchConfiguration configuration) throws CoreException
     {
-        String[] bootpath = super.getBootpath( configuration );
+        String[] bootpath = super.getBootpath(configuration);
 
         ArrayList<String> filtered = new ArrayList<String>();
 
-        if ( bootpath != null )
+        if (bootpath != null)
         {
-            for ( String bp : bootpath )
+            for (String bp : bootpath)
             {
-                if ( !SigilCore.isBundledPath( bp ) )
+                if (!SigilCore.isBundledPath(bp))
                 {
-                    filtered.add( bp );
+                    filtered.add(bp);
                 }
             }
         }
 
-        return filtered.toArray( new String[filtered.size()] );
+        return filtered.toArray(new String[filtered.size()]);
     }
 
-
-    private String[] buildClasspath( IOSGiInstall osgi, ILaunchConfiguration config ) throws CoreException
+    private String[] buildClasspath(IOSGiInstall osgi, ILaunchConfiguration config)
+        throws CoreException
     {
         ArrayList<String> cp = new ArrayList<String>();
 
-        cp.add( Main.class.getProtectionDomain().getCodeSource().getLocation().getFile() );
+        cp.add(Main.class.getProtectionDomain().getCodeSource().getLocation().getFile());
 
-        for ( String c : getClasspath( config ) )
+        for (String c : getClasspath(config))
         {
-            cp.add( c );
+            cp.add(c);
         }
 
-        if ( osgi != null )
+        if (osgi != null)
         {
-            for ( String c : osgi.getType().getClassPath() )
+            for (String c : osgi.getType().getClassPath())
             {
-                cp.add( c );
+                cp.add(c);
             }
         }
 
-        return cp.toArray( new String[cp.size()] );
+        return cp.toArray(new String[cp.size()]);
     }
 
 }
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
index b8230eb..bbb1b50 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
@@ -31,11 +31,13 @@
         public URI[] resolve(URI base) throws URISyntaxException
         {
             ArrayList<URI> uris = new ArrayList<URI>(1);
-            
+
             IBundleResolver resolver = manager.getBundleResolver();
-            IRequiredBundle element = ModelElementFactory.getInstance().newModelElement(IRequiredBundle.class);
+            IRequiredBundle element = ModelElementFactory.getInstance().newModelElement(
+                IRequiredBundle.class);
             String[] parts = base.getSchemeSpecificPart().split(":");
-            switch( parts.length ) {
+            switch (parts.length)
+            {
                 case 2:
                     Version v = Version.parseVersion(parts[1]);
                     element.setVersions(new VersionRange(false, v, v, false));
@@ -44,25 +46,32 @@
                     element.setSymbolicName(parts[0]);
                     break;
                 default:
-                    throw new URISyntaxException(base.toString(), "Unexpected number of parts: " + parts.length);
+                    throw new URISyntaxException(base.toString(),
+                        "Unexpected number of parts: " + parts.length);
             }
             try
             {
-                ResolutionConfig config = new ResolutionConfig(ResolutionConfig.IGNORE_ERRORS);
+                ResolutionConfig config = new ResolutionConfig(
+                    ResolutionConfig.IGNORE_ERRORS);
                 IResolution resolution = resolver.resolve(element, config, null);
-                if ( resolution.getBundles().isEmpty() ) {
-                    SigilCore.error( "Failed to resolve bundle for " + base );
+                if (resolution.getBundles().isEmpty())
+                {
+                    SigilCore.error("Failed to resolve bundle for " + base);
                 }
-                for ( ISigilBundle b : resolution.getBundles() ) {
+                for (ISigilBundle b : resolution.getBundles())
+                {
                     ISigilProjectModel p = b.getAncestor(ISigilProjectModel.class);
-                    if ( p != null ) {
+                    if (p != null)
+                    {
                         uris.add(p.findBundleLocation().toFile().toURI());
-                        SigilCore.log("Adding project source to source path " + p.getName());
+                        SigilCore.log("Adding project source to source path "
+                            + p.getName());
                         SigilSourcePathProvider.addProjectSource(launchConfig, p);
                     }
-                    else {
+                    else
+                    {
                         b.synchronize(null);
-                        uris.add( b.getLocation().toURI() );
+                        uris.add(b.getLocation().toURI());
                     }
                 }
             }
@@ -78,27 +87,29 @@
             {
                 SigilCore.error("Failed to access " + base, e);
             }
-            SigilCore.log( "Resolved " + uris );
+            SigilCore.log("Resolved " + uris);
             return uris.toArray(new URI[uris.size()]);
         }
     }
-    
+
     private final IRepositoryManager manager;
     private final ILaunchConfiguration launchConfig;
-    
-    public RuntimeBundleResolver(IRepositoryManager manager, ILaunchConfiguration launchConfig) {
+
+    public RuntimeBundleResolver(IRepositoryManager manager, ILaunchConfiguration launchConfig)
+    {
         this.manager = manager;
         this.launchConfig = launchConfig;
     }
 
     public Resolver findResolver(URI uri)
     {
-        SigilCore.log( "Finding resolver for " + uri.getScheme() );
-        if ( "sigil".equals( uri.getScheme() ) ) {
-            SigilCore.log( "Found resolver for " + uri.getScheme() );
+        SigilCore.log("Finding resolver for " + uri.getScheme());
+        if ("sigil".equals(uri.getScheme()))
+        {
+            SigilCore.log("Found resolver for " + uri.getScheme());
             return new SigilBundleResolver();
         }
         return null;
     }
-    
+
 }
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java
index f0511ea..ecfba3d 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java
@@ -1,6 +1,5 @@
 package org.apache.felix.sigil.eclipse.runtime.config;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -29,7 +28,6 @@
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 
-
 public class FilteredModelView<T> extends Composite
 {
     private ArrayList<T> selected = new ArrayList<T>();
@@ -39,9 +37,9 @@
     private StructuredViewer viewer;
     private String txt = "";
 
-    public FilteredModelView( Composite parent, int style )
+    public FilteredModelView(Composite parent, int style)
     {
-        super( parent, style );
+        super(parent, style);
         initLayout();
     }
 
@@ -50,42 +48,39 @@
         return selected;
     }
 
-
     public List<T> getElements()
     {
         return elements;
     }
 
-    public void addElement( T element )
+    public void addElement(T element)
     {
-        elements.add( element );
+        elements.add(element);
         refresh();
     }
 
-
-    public void addElements( Collection<T> elements )
+    public void addElements(Collection<T> elements)
     {
-        this.elements.addAll( elements );
+        this.elements.addAll(elements);
         refresh();
     }
 
-
-    public void removeElement( T element )
+    public void removeElement(T element)
     {
-        elements.remove( element );
+        elements.remove(element);
         refresh();
     }
 
-
-    public void removeElements( Collection<T> elements )
+    public void removeElements(Collection<T> elements)
     {
-        this.elements.removeAll( elements );
+        this.elements.removeAll(elements);
         refresh();
     }
 
     public void refresh()
     {
-        SigilUI.runInUI( new Runnable() {
+        SigilUI.runInUI(new Runnable()
+        {
 
             public void run()
             {
@@ -96,108 +91,104 @@
 
     private void initLayout()
     {
-        Text bundleTxt = createSelectionBox( this );
+        Text bundleTxt = createSelectionBox(this);
 
-        Control view = createViewBox( this );
+        Control view = createViewBox(this);
 
         // layout
-        bundleTxt.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        view.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+        bundleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        view.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
-        setLayout( new GridLayout( 1, false ) );
+        setLayout(new GridLayout(1, false));
     }
 
-
-    private Control createViewBox( Composite parent )
+    private Control createViewBox(Composite parent)
     {
-        Table table = new Table( this, SWT.MULTI );
+        Table table = new Table(this, SWT.MULTI);
 
-        viewer = createViewer( table );
+        viewer = createViewer(table);
 
-        viewer.setContentProvider( new ArrayContentProvider() );
+        viewer.setContentProvider(new ArrayContentProvider());
 
-        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        viewer.addSelectionChangedListener(new ISelectionChangedListener()
         {
             @SuppressWarnings("unchecked")
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
-                if ( event.getSelection().isEmpty() )
+                if (event.getSelection().isEmpty())
                 {
                     selected.clear();
                 }
                 else
                 {
-                    IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
-                    selected.addAll( sel.toList() );
+                    IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+                    selected.addAll(sel.toList());
                 }
             }
-        } );
-        
-        viewer.setInput( elements );
+        });
 
-        viewer.setFilters( new ViewerFilter[]
-            { new ViewerFilter()
+        viewer.setInput(elements);
+
+        viewer.setFilters(new ViewerFilter[] { new ViewerFilter()
+        {
+            @SuppressWarnings("unchecked")
+            @Override
+            public boolean select(Viewer viewer, Object parentElement, Object element)
             {
-                @SuppressWarnings("unchecked")
-                @Override
-                public boolean select( Viewer viewer, Object parentElement, Object element )
+                if (filter.select((T) element))
                 {
-                    if ( filter.select( ( T ) element ) )
-                    {
-                        String name = elementDescriptor.getName( ( T ) element );
-                        return name.startsWith( txt );
-                    }
-                    else
-                    {
-                        return false;
-                    }
+                    String name = elementDescriptor.getName((T) element);
+                    return name.startsWith(txt);
                 }
-            } } );
+                else
+                {
+                    return false;
+                }
+            }
+        } });
 
         return table;
     }
 
-
-    protected StructuredViewer createViewer( Table table )
+    protected StructuredViewer createViewer(Table table)
     {
-        TableViewer tableViewer = new TableViewer( table );
-        
-        tableViewer.setLabelProvider( new DefaultLabelProvider() {
+        TableViewer tableViewer = new TableViewer(table);
 
-            public Image getImage( Object arg0 )
+        tableViewer.setLabelProvider(new DefaultLabelProvider()
+        {
+
+            public Image getImage(Object arg0)
             {
                 return null;
             }
 
             @SuppressWarnings("unchecked")
-            public String getText( Object element )
+            public String getText(Object element)
             {
-                return elementDescriptor.getLabel( ( T ) element );
+                return elementDescriptor.getLabel((T) element);
             }
-            
+
         });
 
         return tableViewer;
     }
 
-
-    private Text createSelectionBox( Composite parent )
+    private Text createSelectionBox(Composite parent)
     {
-        final Text txtSelection = new Text( parent, SWT.SEARCH );
+        final Text txtSelection = new Text(parent, SWT.SEARCH);
 
-        txtSelection.addKeyListener( new KeyAdapter()
+        txtSelection.addKeyListener(new KeyAdapter()
         {
             @Override
-            public void keyReleased( KeyEvent e )
+            public void keyReleased(KeyEvent e)
             {
                 txt = txtSelection.getText();
                 refresh();
             }
-        } );
+        });
         return txtSelection;
     }
 
-
     /*
      *         ControlDecoration selectionDecor = new ControlDecoration( txtSelection, SWT.LEFT | SWT.TOP );
         FieldDecoration proposalDecor = FieldDecorationRegistry.getDefault().getFieldDecoration(
@@ -225,28 +216,27 @@
 
      */
 
-    public void setElementDescriptor( IElementDescriptor<T> elementDescriptor )
+    public void setElementDescriptor(IElementDescriptor<T> elementDescriptor)
     {
-        if ( elementDescriptor == null )
+        if (elementDescriptor == null)
         {
             elementDescriptor = UIHelper.getDefaultElementDescriptor();
         }
         this.elementDescriptor = elementDescriptor;
     }
-    
-    public IElementDescriptor<T> getElementDescriptor() {
+
+    public IElementDescriptor<T> getElementDescriptor()
+    {
         return elementDescriptor;
     }
 
-
-    public void setFilter( IFilter<T> filter )
+    public void setFilter(IFilter<T> filter)
     {
-        if ( filter == null )
+        if (filter == null)
         {
             filter = UIHelper.getDefaultFilter();
         }
         this.filter = filter;
     }
 
-
 }
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FormSelectionDialog.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FormSelectionDialog.java
index d1ac51f..001a16d 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FormSelectionDialog.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FormSelectionDialog.java
@@ -22,7 +22,7 @@
 public class FormSelectionDialog extends Dialog
 {
     private IFile formFile;
-    
+
     public FormSelectionDialog(Shell parent)
     {
         super(parent);
@@ -39,45 +39,52 @@
         viewer.setContentProvider(new BaseWorkbenchContentProvider());
         viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
         viewer.addSelectionChangedListener(new ISelectionChangedListener()
-        {        
+        {
             public void selectionChanged(SelectionChangedEvent evt)
             {
-                if (evt.getSelection().isEmpty()) {
+                if (evt.getSelection().isEmpty())
+                {
                     updateFile(null);
                 }
-                else {
+                else
+                {
                     StructuredSelection sel = (StructuredSelection) evt.getSelection();
                     IResource r = (IResource) sel.getFirstElement();
-                    if ( r instanceof IFile ) {
+                    if (r instanceof IFile)
+                    {
                         IFile f = (IFile) r;
                         updateFile(f);
                     }
-                    else {
+                    else
+                    {
                         updateFile(null);
                     }
                 }
             }
         });
         viewer.setLabelProvider(new WorkbenchLabelProvider());
-        
+
         tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-        
+
         return composite;
     }
-    
-    public IFile getFormFile() {
+
+    public IFile getFormFile()
+    {
         return formFile;
     }
 
     protected void updateFile(IFile file)
     {
         formFile = file;
-        
-        if ( file == null ) {
-            getButton(Window.OK).setEnabled(false);            
+
+        if (file == null)
+        {
+            getButton(Window.OK).setEnabled(false);
         }
-        else {
-            getButton(Window.OK).setEnabled(true);            
+        else
+        {
+            getButton(Window.OK).setEnabled(true);
         }
     }
 
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTab.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTab.java
index e3d3179..668fed3 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTab.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTab.java
@@ -21,7 +21,6 @@
 
 import java.net.URL;
 
-
 import org.apache.felix.sigil.common.runtime.BundleForm;
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.runtime.LaunchHelper;
@@ -64,7 +63,7 @@
     /* (non-Javadoc)
      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
      */
-    public void createControl( Composite parent )
+    public void createControl(Composite parent)
     {
         Composite configurationView = new Composite(parent, SWT.NONE);
         new Label(configurationView, SWT.NONE).setText("Form");
@@ -73,8 +72,8 @@
         formText = new Text(configurationView, SWT.BORDER);
 
         // layout
-        formText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
-        
+        formText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
         formText.addKeyListener(new KeyAdapter()
         {
             @Override
@@ -83,25 +82,26 @@
                 updateLocation();
             }
         });
-        
+
         Button browse = new Button(configurationView, SWT.PUSH);
         browse.setText("Browse");
-        
-        browse.addSelectionListener( new SelectionAdapter() {
+
+        browse.addSelectionListener(new SelectionAdapter()
+        {
             @Override
-            public void widgetSelected(SelectionEvent e) {
-                FormSelectionDialog dialog =
-                    new FormSelectionDialog(getShell());
-                if ( dialog.open() == Window.OK ) {
+            public void widgetSelected(SelectionEvent e)
+            {
+                FormSelectionDialog dialog = new FormSelectionDialog(getShell());
+                if (dialog.open() == Window.OK)
+                {
                     formLocation = dialog.getFormFile().getFullPath().toOSString();
                     formText.setText(formLocation);
                     updateLocation();
                 }
             }
         });
-        
-        
-        configurationView.setLayout( new GridLayout( 3, false ) );
+
+        configurationView.setLayout(new GridLayout(3, false));
 
         setControl(configurationView);
     }
@@ -109,7 +109,8 @@
     private void updateLocation()
     {
         String loc = formText.getText();
-        if ( loc.trim().length() > 0 ) {
+        if (loc.trim().length() > 0)
+        {
             try
             {
                 URL url = LaunchHelper.toURL(loc);
@@ -121,10 +122,11 @@
             catch (Exception e)
             {
                 SigilCore.warn("Failed to resolve bundle form", e);
-                setErrorMessage("Invalid form file " + e.getMessage() );
+                setErrorMessage("Invalid form file " + e.getMessage());
             }
         }
-        else {
+        else
+        {
             setErrorMessage("Missing form file");
         }
         updateLaunchConfigurationDialog();
@@ -133,11 +135,12 @@
     /* (non-Javadoc)
      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
      */
-    public void initializeFrom( ILaunchConfiguration config )
+    public void initializeFrom(ILaunchConfiguration config)
     {
         try
         {
-            formLocation = config.getAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, "");
+            formLocation = config.getAttribute(
+                OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, "");
             formText.setText(formLocation);
         }
         catch (CoreException e)
@@ -149,18 +152,22 @@
     /* (non-Javadoc)
      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
      */
-    public void performApply( ILaunchConfigurationWorkingCopy config )
+    public void performApply(ILaunchConfigurationWorkingCopy config)
     {
-        config.setAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, formLocation);
-        config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, OSGiLaunchConfigurationConstants.CLASSPATH_PROVIDER );
-        config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, OSGiLaunchConfigurationConstants.CLASSPATH_PROVIDER);    
+        config.setAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION,
+            formLocation);
+        config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER,
+            OSGiLaunchConfigurationConstants.CLASSPATH_PROVIDER);
+        config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
+            OSGiLaunchConfigurationConstants.CLASSPATH_PROVIDER);
     }
 
     /* (non-Javadoc)
      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
      */
-    public void setDefaults( ILaunchConfigurationWorkingCopy config )
+    public void setDefaults(ILaunchConfigurationWorkingCopy config)
     {
-        config.setAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, (String) null);
+        config.setAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION,
+            (String) null);
     }
 }
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTabGroup.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTabGroup.java
index 77834a0..1acaa4e 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTabGroup.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTabGroup.java
@@ -37,16 +37,12 @@
     /* (non-Javadoc)
      * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
      */
-    public void createTabs( ILaunchConfigurationDialog arg0, String arg1 )
+    public void createTabs(ILaunchConfigurationDialog arg0, String arg1)
     {
         ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
-            new OSGiLaunchConfigurationTab(),
-            new CommonTab(),
-            new JavaArgumentsTab(),
-            new JavaClasspathTab(),
-            new EnvironmentTab()
-        };
-        setTabs(tabs);    
+                new OSGiLaunchConfigurationTab(), new CommonTab(),
+                new JavaArgumentsTab(), new JavaClasspathTab(), new EnvironmentTab() };
+        setTabs(tabs);
     }
 
 }
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/shortcut/OSGiLaunchShortCut.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/shortcut/OSGiLaunchShortCut.java
index 8b83917..7e2f426 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/shortcut/OSGiLaunchShortCut.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/shortcut/OSGiLaunchShortCut.java
@@ -33,19 +33,19 @@
     /* (non-Javadoc)
      * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
      */
-    public void launch( ISelection arg0, String arg1 )
+    public void launch(ISelection arg0, String arg1)
     {
         // TODO Auto-generated method stub
-        
+
     }
 
     /* (non-Javadoc)
      * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
      */
-    public void launch( IEditorPart arg0, String arg1 )
+    public void launch(IEditorPart arg0, String arg1)
     {
         // TODO Auto-generated method stub
-        
+
     }
 
 }
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/source/SigilSourcePathProvider.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/source/SigilSourcePathProvider.java
index 2b6f170..31c6091 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/source/SigilSourcePathProvider.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/source/SigilSourcePathProvider.java
@@ -25,126 +25,138 @@
     public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries,
         ILaunchConfiguration configuration) throws CoreException
     {
-        ArrayList<IRuntimeClasspathEntry> all = new ArrayList<IRuntimeClasspathEntry>(entries.length);
-        
-        all.addAll( workbenchSourcePath(entries, configuration) );
-//        all.addAll( launchOverridePath( configuration ) );
-//        all.addAll( newtonSourcePath( configuration ) );
-        Set<IRuntimeClasspathEntry> dynamic = dynamicRuntime.get( configuration );
-        if ( dynamic != null ) {
-            all.addAll( dynamic );
+        ArrayList<IRuntimeClasspathEntry> all = new ArrayList<IRuntimeClasspathEntry>(
+            entries.length);
+
+        all.addAll(workbenchSourcePath(entries, configuration));
+        //        all.addAll( launchOverridePath( configuration ) );
+        //        all.addAll( newtonSourcePath( configuration ) );
+        Set<IRuntimeClasspathEntry> dynamic = dynamicRuntime.get(configuration);
+        if (dynamic != null)
+        {
+            all.addAll(dynamic);
         }
-        
-        return (IRuntimeClasspathEntry[]) all
-                .toArray(new IRuntimeClasspathEntry[all.size()]);
+
+        return (IRuntimeClasspathEntry[]) all.toArray(new IRuntimeClasspathEntry[all.size()]);
     }
 
-    private List<IRuntimeClasspathEntry> workbenchSourcePath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException {
-        return Arrays.asList( super.resolveClasspath(entries, configuration) );
+    private List<IRuntimeClasspathEntry> workbenchSourcePath(
+        IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration)
+        throws CoreException
+    {
+        return Arrays.asList(super.resolveClasspath(entries, configuration));
     }
-    
-    private Collection<IRuntimeClasspathEntry> launchOverridePath(ILaunchConfiguration configuration) throws CoreException {
+
+    private Collection<IRuntimeClasspathEntry> launchOverridePath(
+        ILaunchConfiguration configuration) throws CoreException
+    {
         ArrayList<IRuntimeClasspathEntry> overrides = new ArrayList<IRuntimeClasspathEntry>();
-        
-        if ( configuration.getAttribute( OSGiLaunchConfigurationConstants.AUTOMATIC_ADD, true) ) {
-            for ( ISigilProjectModel n : SigilCore.getRoot().getProjects() ) {
-                overrides.add( JavaRuntime.newProjectRuntimeClasspathEntry(n.getJavaModel()));
-            }           
+
+        if (configuration.getAttribute(OSGiLaunchConfigurationConstants.AUTOMATIC_ADD,
+            true))
+        {
+            for (ISigilProjectModel n : SigilCore.getRoot().getProjects())
+            {
+                overrides.add(JavaRuntime.newProjectRuntimeClasspathEntry(n.getJavaModel()));
+            }
         }
-        
+
         return overrides;
     }
 
-    public static void addProjectSource(ILaunchConfiguration config, ISigilProjectModel project) {
-        Set<IRuntimeClasspathEntry> dynamic = dynamicRuntime.get( config );
-        
-        if ( dynamic == null ) {
+    public static void addProjectSource(ILaunchConfiguration config,
+        ISigilProjectModel project)
+    {
+        Set<IRuntimeClasspathEntry> dynamic = dynamicRuntime.get(config);
+
+        if (dynamic == null)
+        {
             dynamic = new HashSet<IRuntimeClasspathEntry>();
-            dynamicRuntime.put( config, dynamic );
+            dynamicRuntime.put(config, dynamic);
         }
-        
+
         IJavaProject javaProject = project.getJavaModel();
         IRuntimeClasspathEntry cp = JavaRuntime.newProjectRuntimeClasspathEntry(javaProject);
-        
-        dynamic.add( cp );
-    }    
-    
-//    private List<IRuntimeClasspathEntry> newtonSourcePath( ILaunchConfiguration configuration ) throws CoreException {
-//        List<IRuntimeClasspathEntry> all = new ArrayList<IRuntimeClasspathEntry>();
-//        
-////        Collection<IPath> jars = findNewtonJars( configuration );
-//        
-////        IPath source = findSourcePath( configuration );
-//        
-////        for ( IPath jar : jars ) {
-////            IRuntimeClasspathEntry cp = JavaRuntime.newArchiveRuntimeClasspathEntry(jar);
-////            
-////            if ( source != null ) {
-////                cp.setSourceAttachmentPath( source );
-////                cp.setSourceAttachmentRootPath( findSrcDir( source ) );
-////            }
-////            cp.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-////            
-////            all.add( cp );
-////        }
-//                
-//        return all;
-//    }
-    
-//    @SuppressWarnings("unchecked")
-//    private IPath findSrcDir( IPath sourceZip ) throws CoreException {
-//        ZipFile zip = null;
-//        
-//        IPath path = null;
-//        
-//        try {
-//            File file = sourceZip.toFile();
-//            if (file.exists() && file.isFile() ) {
-//                zip = new ZipFile(file);
-//                
-//                for ( Enumeration e = zip.entries(); e.hasMoreElements(); ) {
-//                    ZipEntry entry = (ZipEntry) e.nextElement();
-//                    if ( entry.getName().endsWith( "src/" ) ); {
-//                        path = new Path( entry.getName() );
-//                        break;
-//                    }
-//                }
-//            } // else return null;
-//        }
-//        catch (ZipException e) {
-//            throw SigilCore.newCoreException("Failed to open source zip:" + sourceZip.toFile(), e);
-//        }
-//        catch (IOException e) {
-//            throw SigilCore.newCoreException("Failed to open source zip" + sourceZip.toFile(), e);
-//        }
-//        finally {
-//            if ( zip != null ) {
-//                try {
-//                    zip.close();
-//                }
-//                catch (IOException e) {
-//                    SigilCore.error( "Failed to close src zip", e);
-//                }
-//            }
-//        }
-//        
-//        return path;
-//    }
-    
-//    private Collection<IPath> findNewtonJars( ILaunchConfiguration configuration ) throws CoreException {
-//        ArrayList<IPath> paths = new ArrayList<IPath>();
-//        
-//        INewtonInstall install = NewtonLaunchConfigurationHelper.getNewtonInstall(configuration);
-//        
-//        for ( IPath path : install.getType().getDefaultBundleLocations() ) {
-//            paths.add(path);
-//        }
-//        
-//        return paths;
-//    }       
-    
-//    private IPath findSourcePath( ILaunchConfiguration configuration ) throws CoreException {
-//        INewtonInstall install = NewtonLaunchConfigurationHelper.getNewtonInstall(configuration);
-//        return install.getType().getSourceLocation();
-//    }    
+
+        dynamic.add(cp);
+    }
+
+    //    private List<IRuntimeClasspathEntry> newtonSourcePath( ILaunchConfiguration configuration ) throws CoreException {
+    //        List<IRuntimeClasspathEntry> all = new ArrayList<IRuntimeClasspathEntry>();
+    //        
+    ////        Collection<IPath> jars = findNewtonJars( configuration );
+    //        
+    ////        IPath source = findSourcePath( configuration );
+    //        
+    ////        for ( IPath jar : jars ) {
+    ////            IRuntimeClasspathEntry cp = JavaRuntime.newArchiveRuntimeClasspathEntry(jar);
+    ////            
+    ////            if ( source != null ) {
+    ////                cp.setSourceAttachmentPath( source );
+    ////                cp.setSourceAttachmentRootPath( findSrcDir( source ) );
+    ////            }
+    ////            cp.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
+    ////            
+    ////            all.add( cp );
+    ////        }
+    //                
+    //        return all;
+    //    }
+
+    //    @SuppressWarnings("unchecked")
+    //    private IPath findSrcDir( IPath sourceZip ) throws CoreException {
+    //        ZipFile zip = null;
+    //        
+    //        IPath path = null;
+    //        
+    //        try {
+    //            File file = sourceZip.toFile();
+    //            if (file.exists() && file.isFile() ) {
+    //                zip = new ZipFile(file);
+    //                
+    //                for ( Enumeration e = zip.entries(); e.hasMoreElements(); ) {
+    //                    ZipEntry entry = (ZipEntry) e.nextElement();
+    //                    if ( entry.getName().endsWith( "src/" ) ); {
+    //                        path = new Path( entry.getName() );
+    //                        break;
+    //                    }
+    //                }
+    //            } // else return null;
+    //        }
+    //        catch (ZipException e) {
+    //            throw SigilCore.newCoreException("Failed to open source zip:" + sourceZip.toFile(), e);
+    //        }
+    //        catch (IOException e) {
+    //            throw SigilCore.newCoreException("Failed to open source zip" + sourceZip.toFile(), e);
+    //        }
+    //        finally {
+    //            if ( zip != null ) {
+    //                try {
+    //                    zip.close();
+    //                }
+    //                catch (IOException e) {
+    //                    SigilCore.error( "Failed to close src zip", e);
+    //                }
+    //            }
+    //        }
+    //        
+    //        return path;
+    //    }
+
+    //    private Collection<IPath> findNewtonJars( ILaunchConfiguration configuration ) throws CoreException {
+    //        ArrayList<IPath> paths = new ArrayList<IPath>();
+    //        
+    //        INewtonInstall install = NewtonLaunchConfigurationHelper.getNewtonInstall(configuration);
+    //        
+    //        for ( IPath path : install.getType().getDefaultBundleLocations() ) {
+    //            paths.add(path);
+    //        }
+    //        
+    //        return paths;
+    //    }       
+
+    //    private IPath findSourcePath( ILaunchConfiguration configuration ) throws CoreException {
+    //        INewtonInstall install = NewtonLaunchConfigurationHelper.getNewtonInstall(configuration);
+    //        return install.getType().getSourceLocation();
+    //    }    
 }
diff --git a/sigil/eclipse/search/src/org/apache/felix/sigil/search/ISearchResult.java b/sigil/eclipse/search/src/org/apache/felix/sigil/search/ISearchResult.java
index e22df6c..568ada8 100644
--- a/sigil/eclipse/search/src/org/apache/felix/sigil/search/ISearchResult.java
+++ b/sigil/eclipse/search/src/org/apache/felix/sigil/search/ISearchResult.java
@@ -19,21 +19,16 @@
 
 package org.apache.felix.sigil.search;
 
-
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.common.model.osgi.IPackageExport;
 
-
 public interface ISearchResult
 {
     ISigilBundle getProvider();
 
-
     IPackageExport getExport();
 
-
     String getPackageName();
 
-
     String getClassName();
 }
diff --git a/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java b/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
index d850579..316785c 100644
--- a/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
+++ b/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.search;
 
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
@@ -53,7 +52,6 @@
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
-
 /**
  * The activator class controls the plug-in life cycle
  */
@@ -69,7 +67,6 @@
     private static SigilSearch plugin;
     private static Index index;
 
-
     /**
      * The constructor
      */
@@ -77,45 +74,40 @@
     {
     }
 
-
-    public static List<ISearchResult> findProviders( String fullyQualifiedName, ISigilProjectModel sigil,
-        IProgressMonitor monitor )
+    public static List<ISearchResult> findProviders(String fullyQualifiedName,
+        ISigilProjectModel sigil, IProgressMonitor monitor)
     {
-        listen( sigil );
-        return index.findProviders( fullyQualifiedName, monitor );
+        listen(sigil);
+        return index.findProviders(fullyQualifiedName, monitor);
     }
 
-
-    public static List<ISearchResult> findProviders( Pattern namePattern, ISigilProjectModel sigil,
-        IProgressMonitor monitor )
+    public static List<ISearchResult> findProviders(Pattern namePattern,
+        ISigilProjectModel sigil, IProgressMonitor monitor)
     {
-        listen( sigil );
-        return index.findProviders( namePattern, monitor );
+        listen(sigil);
+        return index.findProviders(namePattern, monitor);
     }
 
-
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
      */
-    public void start( BundleContext context ) throws Exception
+    public void start(BundleContext context) throws Exception
     {
-        super.start( context );
+        super.start(context);
         plugin = this;
     }
 
-
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
      */
-    public void stop( BundleContext context ) throws Exception
+    public void stop(BundleContext context) throws Exception
     {
         plugin = null;
-        super.stop( context );
+        super.stop(context);
     }
 
-
     /**
      * Returns the shared instance
      *
@@ -126,156 +118,157 @@
         return plugin;
     }
 
-
-    private static void listen( ISigilProjectModel sigil )
+    private static void listen(ISigilProjectModel sigil)
     {
-        synchronized ( plugin )
+        synchronized (plugin)
         {
-            if ( index == null )
+            if (index == null)
             {
                 index = new Index();
-                for ( IBundleRepository rep : SigilCore.getRepositoryManager( sigil ).getRepositories() )
+                for (IBundleRepository rep : SigilCore.getRepositoryManager(sigil).getRepositories())
                 {
-                    index( index, rep );
+                    index(index, rep);
                 }
 
-                SigilCore.getRepositoryManager( sigil ).addRepositoryChangeListener( new IRepositoryChangeListener()
-                {
-                    public void repositoryChanged( RepositoryChangeEvent event )
+                SigilCore.getRepositoryManager(sigil).addRepositoryChangeListener(
+                    new IRepositoryChangeListener()
                     {
-                        index( index, event.getRepository() );
-                    }
-                } );
+                        public void repositoryChanged(RepositoryChangeEvent event)
+                        {
+                            index(index, event.getRepository());
+                        }
+                    });
             }
         }
     }
 
-
-    private static void index( final Index index, final IBundleRepository rep )
+    private static void index(final Index index, final IBundleRepository rep)
     {
-        index.delete( rep );
-        rep.accept( new IRepositoryVisitor()
+        index.delete(rep);
+        rep.accept(new IRepositoryVisitor()
         {
-            public boolean visit( ISigilBundle bundle )
+            public boolean visit(ISigilBundle bundle)
             {
-                ISigilProjectModel p = bundle.getAncestor( ISigilProjectModel.class );
-                if ( p == null )
+                ISigilProjectModel p = bundle.getAncestor(ISigilProjectModel.class);
+                if (p == null)
                 {
-                    if ( bundle.isSynchronized() )
+                    if (bundle.isSynchronized())
                     {
                         IPath loc = PathUtil.newPathIfExists(bundle.getLocation());
-                        if ( loc == null ) {
+                        if (loc == null)
+                        {
                             SigilCore.error("Location is null for " + bundle);
                         }
-                        else {
-                            if ( loc.isAbsolute() )
+                        else
+                        {
+                            if (loc.isAbsolute())
                             {
-                                indexJar( rep, bundle, loc );
+                                indexJar(rep, bundle, loc);
                             }
                         }
                     }
                 }
                 else
                 {
-                    indexProject( rep, p );
+                    indexProject(rep, p);
                 }
                 return true;
             }
-        } );
+        });
     }
 
-
-    private static void indexProject( IBundleRepository rep, ISigilProjectModel sigil )
+    private static void indexProject(IBundleRepository rep, ISigilProjectModel sigil)
     {
         try
         {
-            for ( ICompilationUnit unit : JavaHelper.findCompilationUnits( sigil ) )
+            for (ICompilationUnit unit : JavaHelper.findCompilationUnits(sigil))
             {
-                IPackageFragment p = ( IPackageFragment ) unit.getParent();
+                IPackageFragment p = (IPackageFragment) unit.getParent();
                 ISigilBundle b = sigil.getBundle();
-                IPackageExport export = b.findExport( p.getElementName() );
-                index.addEntry( unit, rep, b, export != null );
+                IPackageExport export = b.findExport(p.getElementName());
+                index.addEntry(unit, rep, b, export != null);
             }
         }
-        catch ( JavaModelException e )
+        catch (JavaModelException e)
         {
-            SigilCore.error( "Failed to index project", e);
+            SigilCore.error("Failed to index project", e);
         }
     }
 
-
-    private static void indexJar( IBundleRepository rep, ISigilBundle bundle, IPath loc )
+    private static void indexJar(IBundleRepository rep, ISigilBundle bundle, IPath loc)
     {
         JarFile jar = null;
         try
         {
-            jar = new JarFile( loc.toOSString() );
-            for ( Map.Entry<JarEntry, IPackageExport> export : findExportedClasses( bundle, jar ).entrySet() )
+            jar = new JarFile(loc.toOSString());
+            for (Map.Entry<JarEntry, IPackageExport> export : findExportedClasses(bundle,
+                jar).entrySet())
             {
                 JarEntry entry = export.getKey();
                 InputStream in = null;
                 try
                 {
-                    in = jar.getInputStream( entry );
-                    ClassParser parser = new ClassParser( in, entry.getName() );
+                    in = jar.getInputStream(entry);
+                    ClassParser parser = new ClassParser(in, entry.getName());
                     JavaClass c = parser.parse();
-                    index.addEntry( c, rep, bundle, true );
+                    index.addEntry(c, rep, bundle, true);
                 }
                 finally
                 {
-                    if ( in != null )
+                    if (in != null)
                     {
                         in.close();
                     }
                 }
             }
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
-            SigilCore.error( "Failed to read jar " + loc, e );
+            SigilCore.error("Failed to read jar " + loc, e);
         }
         finally
         {
-            if ( jar != null )
+            if (jar != null)
             {
                 try
                 {
                     jar.close();
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
-                    SigilCore.error( "Failed to close jar " + loc, e );
+                    SigilCore.error("Failed to close jar " + loc, e);
                 }
             }
         }
     }
 
-
-    private static Map<JarEntry, IPackageExport> findExportedClasses( ISigilBundle bundle, JarFile jar )
+    private static Map<JarEntry, IPackageExport> findExportedClasses(ISigilBundle bundle,
+        JarFile jar)
     {
         HashMap<JarEntry, IPackageExport> found = new HashMap<JarEntry, IPackageExport>();
 
-        IPackageExport[] exports = bundle.getBundleInfo().childrenOfType( IPackageExport.class );
-        if ( exports.length > 0 )
+        IPackageExport[] exports = bundle.getBundleInfo().childrenOfType(
+            IPackageExport.class);
+        if (exports.length > 0)
         {
-            Arrays.sort( exports, new Comparator<IPackageExport>()
+            Arrays.sort(exports, new Comparator<IPackageExport>()
             {
-                public int compare( IPackageExport o1, IPackageExport o2 )
+                public int compare(IPackageExport o1, IPackageExport o2)
                 {
-                    return -1 * o1.compareTo( o2 );
+                    return -1 * o1.compareTo(o2);
                 }
-            } );
-            for ( Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements(); )
+            });
+            for (Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements();)
             {
                 JarEntry entry = e.nextElement();
-                String className = toClassName( entry );
-                if ( className != null )
+                String className = toClassName(entry);
+                if (className != null)
                 {
-                    IPackageExport ex = findExport( className, exports );
+                    IPackageExport ex = findExport(className, exports);
 
-                    if ( found != null )
+                    if (found != null)
                     {
-                        found.put( entry, ex );
+                        found.put(entry, ex);
                     }
                 }
             }
@@ -284,12 +277,11 @@
         return found;
     }
 
-
-    private static IPackageExport findExport( String className, IPackageExport[] exports )
+    private static IPackageExport findExport(String className, IPackageExport[] exports)
     {
-        for ( IPackageExport e : exports )
+        for (IPackageExport e : exports)
         {
-            if ( className.startsWith( e.getPackageName() ) )
+            if (className.startsWith(e.getPackageName()))
             {
                 return e;
             }
@@ -297,14 +289,13 @@
         return null;
     }
 
-
-    private static String toClassName( JarEntry entry )
+    private static String toClassName(JarEntry entry)
     {
         String name = entry.getName();
-        if ( name.endsWith( CLASS_EXTENSION ) )
+        if (name.endsWith(CLASS_EXTENSION))
         {
-            name = name.substring( 0, name.length() - CLASS_EXTENSION.length() );
-            name = name.replace( '/', '.' );
+            name = name.substring(0, name.length() - CLASS_EXTENSION.length());
+            name = name.replace('/', '.');
             return name;
         }
         else
diff --git a/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java b/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java
index 7427b65..8d20b27 100644
--- a/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java
+++ b/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.search.index;
 
-
 import java.lang.ref.SoftReference;
 import java.util.Collections;
 import java.util.HashMap;
@@ -45,7 +44,6 @@
 import org.eclipse.jdt.core.IPackageFragment;
 import org.osgi.framework.Version;
 
-
 public class Index
 {
     private HashMap<String, ClassData> primary = new HashMap<String, ClassData>();
@@ -57,38 +55,34 @@
     {
         HashMap<IBundleRepository, Set<ISearchResult>> provided = new HashMap<IBundleRepository, Set<ISearchResult>>();
 
-
-        void add( IBundleRepository rep, ISearchResult export )
+        void add(IBundleRepository rep, ISearchResult export)
         {
-            Set<ISearchResult> exports = provided.get( rep );
+            Set<ISearchResult> exports = provided.get(rep);
 
-            if ( exports == null )
+            if (exports == null)
             {
                 exports = new HashSet<ISearchResult>();
-                provided.put( rep, exports );
+                provided.put(rep, exports);
             }
 
-            exports.add( export );
+            exports.add(export);
         }
 
-
         List<ISearchResult> getResults()
         {
             LinkedList<ISearchResult> exports = new LinkedList<ISearchResult>();
-            for ( Set<ISearchResult> p : provided.values() )
+            for (Set<ISearchResult> p : provided.values())
             {
-                exports.addAll( p );
+                exports.addAll(p);
             }
             return exports;
         }
 
-
-        void remove( IBundleRepository rep )
+        void remove(IBundleRepository rep)
         {
-            provided.remove( rep );
+            provided.remove(rep);
         }
 
-
         boolean isEmpty()
         {
             return provided.isEmpty();
@@ -107,9 +101,7 @@
         private SoftReference<ISigilBundle> bundleReference;
         private SoftReference<IPackageExport> exportReference;
 
-
-        public SearchResult( String className, IBundleRepository rep, ISigilBundle bundle, String packageName,
-            boolean exported )
+        public SearchResult(String className, IBundleRepository rep, ISigilBundle bundle, String packageName, boolean exported)
         {
             this.className = className;
             this.rep = rep;
@@ -119,99 +111,97 @@
             this.packageName = packageName;
         }
 
-
         public String getClassName()
         {
             return className;
         }
 
-
         public String getPackageName()
         {
             return packageName;
         }
 
-
         public IPackageExport getExport()
         {
             IPackageExport ipe = null;
-            if ( exported )
+            if (exported)
             {
                 ipe = exportReference == null ? null : exportReference.get();
-                if ( ipe == null )
+                if (ipe == null)
                 {
-                    ipe = getProvider().findExport( packageName );
-                    exportReference = new SoftReference<IPackageExport>( ipe );
+                    ipe = getProvider().findExport(packageName);
+                    exportReference = new SoftReference<IPackageExport>(ipe);
                 }
             }
             return ipe;
         }
 
-
         public ISigilBundle getProvider()
         {
             ISigilBundle b = bundleReference == null ? null : bundleReference.get();
-            if ( b == null )
+            if (b == null)
             {
-                IRequiredBundle rb = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
-                rb.setSymbolicName( bundleSymbolicName );
-                VersionRange versions = new VersionRange( false, version, version, false );
-                rb.setVersions( versions );
-                b = rep.findProvider( rb, 0 );
-                bundleReference = new SoftReference<ISigilBundle>( b );
+                IRequiredBundle rb = ModelElementFactory.getInstance().newModelElement(
+                    IRequiredBundle.class);
+                rb.setSymbolicName(bundleSymbolicName);
+                VersionRange versions = new VersionRange(false, version, version, false);
+                rb.setVersions(versions);
+                b = rep.findProvider(rb, 0);
+                bundleReference = new SoftReference<ISigilBundle>(b);
             }
             return b;
         }
 
     }
 
-
-    public void addEntry( JavaClass c, IBundleRepository rep, ISigilBundle bundle, boolean exported )
+    public void addEntry(JavaClass c, IBundleRepository rep, ISigilBundle bundle,
+        boolean exported)
     {
-        addEntry( c.getClassName(), rep, bundle, c.getPackageName(), exported );
+        addEntry(c.getClassName(), rep, bundle, c.getPackageName(), exported);
     }
 
-
-    public void addEntry( ICompilationUnit unit, IBundleRepository rep, ISigilBundle bundle, boolean exported )
+    public void addEntry(ICompilationUnit unit, IBundleRepository rep,
+        ISigilBundle bundle, boolean exported)
     {
         String name = unit.getElementName();
-        if ( name.endsWith( ".java" ) )
+        if (name.endsWith(".java"))
         {
-            name = name.substring( 0, name.length() - 5 );
+            name = name.substring(0, name.length() - 5);
         }
-        IPackageFragment p = ( IPackageFragment ) unit.getAncestor( IJavaElement.PACKAGE_FRAGMENT );
-        addEntry( p.getElementName() + "." + name, rep, bundle, p.getElementName(), exported );
+        IPackageFragment p = (IPackageFragment) unit.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
+        addEntry(p.getElementName() + "." + name, rep, bundle, p.getElementName(),
+            exported);
     }
 
-
-    private void addEntry( String className, IBundleRepository rep, ISigilBundle bundle, String packageName,
-        boolean exported )
+    private void addEntry(String className, IBundleRepository rep, ISigilBundle bundle,
+        String packageName, boolean exported)
     {
-        List<String> keys = genKeys( className );
+        List<String> keys = genKeys(className);
         lock.writeLock().lock();
         try
         {
-            for ( String key : keys )
+            for (String key : keys)
             {
-                ClassData data = primary.get( key );
+                ClassData data = primary.get(key);
 
-                if ( data == null )
+                if (data == null)
                 {
                     data = new ClassData();
-                    primary.put( key, data );
+                    primary.put(key, data);
                 }
 
-                SearchResult result = new SearchResult( className, rep, bundle, packageName, exported );
-                data.add( rep, result );
+                SearchResult result = new SearchResult(className, rep, bundle,
+                    packageName, exported);
+                data.add(rep, result);
             }
 
-            HashSet<String> all = secondary.get( rep );
-            if ( all == null )
+            HashSet<String> all = secondary.get(rep);
+            if (all == null)
             {
                 all = new HashSet<String>();
-                secondary.put( rep, all );
+                secondary.put(rep, all);
             }
-            all.addAll( keys );
+            all.addAll(keys);
         }
         finally
         {
@@ -219,14 +209,14 @@
         }
     }
 
-
-    public List<ISearchResult> findProviders( String className, IProgressMonitor monitor )
+    public List<ISearchResult> findProviders(String className, IProgressMonitor monitor)
     {
         lock.readLock().lock();
         try
         {
-            ClassData data = primary.get( className );
-            return data == null ? Collections.<ISearchResult> emptyList() : data.getResults();
+            ClassData data = primary.get(className);
+            return data == null ? Collections.<ISearchResult> emptyList()
+                : data.getResults();
         }
         finally
         {
@@ -234,14 +224,14 @@
         }
     }
 
-
-    public List<ISearchResult> findProviders( Pattern className, IProgressMonitor monitor )
+    public List<ISearchResult> findProviders(Pattern className, IProgressMonitor monitor)
     {
         lock.readLock().lock();
         try
         {
-            ClassData data = primary.get( className );
-            return data == null ? Collections.<ISearchResult> emptyList() : data.getResults();
+            ClassData data = primary.get(className);
+            return data == null ? Collections.<ISearchResult> emptyList()
+                : data.getResults();
         }
         finally
         {
@@ -249,22 +239,21 @@
         }
     }
 
-
-    public void delete( IBundleRepository rep )
+    public void delete(IBundleRepository rep)
     {
         lock.writeLock().lock();
         try
         {
-            Set<String> keys = secondary.remove( rep );
-            if ( keys != null )
+            Set<String> keys = secondary.remove(rep);
+            if (keys != null)
             {
-                for ( String key : keys )
+                for (String key : keys)
                 {
-                    ClassData data = primary.get( key );
-                    data.remove( rep );
-                    if ( data.isEmpty() )
+                    ClassData data = primary.get(key);
+                    data.remove(rep);
+                    if (data.isEmpty())
                     {
-                        primary.remove( key );
+                        primary.remove(key);
                     }
                 }
             }
@@ -275,16 +264,15 @@
         }
     }
 
-
-    private List<String> genKeys( String className )
+    private List<String> genKeys(String className)
     {
         LinkedList<String> keys = new LinkedList<String>();
-        keys.add( className );
-        int i = className.lastIndexOf( '.' );
-        if ( i != -1 )
+        keys.add(className);
+        int i = className.lastIndexOf('.');
+        if (i != -1)
         {
-            String name = className.substring( i + 1 );
-            keys.add( name );
+            String name = className.substring(i + 1);
+            keys.add(name);
         }
         return keys;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/SigilUI.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/SigilUI.java
index ccd3191..9b427f9 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/SigilUI.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/SigilUI.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui;
 
-
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Locale;
@@ -39,7 +38,6 @@
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
-
 /**
  * The activator class controls the plug-in life cycle
  */
@@ -56,13 +54,12 @@
 
     public static final String ID_REPOSITORY_VIEW = "org.apache.felix.sigil.ui.repositoryBrowser";
     public static final String ID_DEPENDENCY_VIEW = "org.apache.felix.sigil.ui.bundleDependencyView";
-    
+
     public static final String WORKSPACE_REPOSITORY_ID = "org.apache.felix.sigil.core.workspaceprovider";
 
     // The shared instance
     private static SigilUI plugin;
 
-
     /**
      * The constructor
      */
@@ -70,30 +67,27 @@
     {
     }
 
-
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
      */
-    public void start( BundleContext context ) throws Exception
+    public void start(BundleContext context) throws Exception
     {
-        super.start( context );
+        super.start(context);
         SigilCore.getDefault();
         plugin = this;
     }
 
-
     /*
      * (non-Javadoc)
      * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
      */
-    public void stop( BundleContext context ) throws Exception
+    public void stop(BundleContext context) throws Exception
     {
         plugin = null;
-        super.stop( context );
+        super.stop(context);
     }
 
-
     /**
      * Returns the shared instance
      *
@@ -104,81 +98,76 @@
         return plugin;
     }
 
-
     public static ResourceBundle getResourceBundle()
     {
-        return ResourceBundle.getBundle( "resources." + SigilUI.class.getName(), Locale.getDefault(), SigilUI.class
-            .getClassLoader() );
+        return ResourceBundle.getBundle("resources." + SigilUI.class.getName(),
+            Locale.getDefault(), SigilUI.class.getClassLoader());
     }
 
-
-    public static void runWorkspaceOperation( IRunnableWithProgress op, Shell shell )
+    public static void runWorkspaceOperation(IRunnableWithProgress op, Shell shell)
     {
-        if ( shell == null )
+        if (shell == null)
         {
             shell = getActiveWorkbenchShell();
         }
         try
         {
-            new ProgressMonitorDialog( shell ).run( true, true, op );
+            new ProgressMonitorDialog(shell).run(true, true, op);
         }
-        catch ( InvocationTargetException e )
+        catch (InvocationTargetException e)
         {
-            SigilCore.error( "Workspace operation failed", e );
+            SigilCore.error("Workspace operation failed", e);
         }
-        catch ( InterruptedException e1 )
+        catch (InterruptedException e1)
         {
-            SigilCore.log( "Workspace operation interrupted" );
+            SigilCore.log("Workspace operation interrupted");
         }
     }
 
-
-    public static void runWorkspaceOperationSync( IRunnableWithProgress op, Shell shell ) throws Throwable
+    public static void runWorkspaceOperationSync(IRunnableWithProgress op, Shell shell)
+        throws Throwable
     {
-        if ( shell == null )
+        if (shell == null)
         {
             shell = getActiveWorkbenchShell();
         }
         try
         {
-            new ProgressMonitorDialog( shell ).run( false, true, op );
+            new ProgressMonitorDialog(shell).run(false, true, op);
         }
-        catch ( InvocationTargetException e )
+        catch (InvocationTargetException e)
         {
             throw e.getCause();
         }
-        catch ( InterruptedException e1 )
+        catch (InterruptedException e1)
         {
-            SigilCore.log( "Workspace operation interrupted" );
+            SigilCore.log("Workspace operation interrupted");
         }
     }
 
-
     public static IWorkbenchWindow getActiveWorkbenchWindow()
     {
         return getDefault().getWorkbench().getActiveWorkbenchWindow();
     }
 
-
     public static Shell getActiveWorkbenchShell()
     {
         final Shell[] shell = new Shell[1];
-        runInUISync( new Runnable()
+        runInUISync(new Runnable()
         {
             public void run()
             {
                 shell[0] = getActiveDisplay().getActiveShell();
             }
-        } );
+        });
         return shell[0];
     }
 
-
     public static Display getActiveDisplay()
     {
         Display d = Display.getCurrent();
 
-        if ( d == null )
+        if (d == null)
         {
             d = Display.getDefault();
         }
@@ -186,10 +175,9 @@
         return d;
     }
 
-
-    public static void runInUI( Runnable runnable )
+    public static void runInUI(Runnable runnable)
     {
-        getActiveDisplay().asyncExec( runnable );
+        getActiveDisplay().asyncExec(runnable);
     }
 
     @SuppressWarnings("unchecked")
@@ -197,7 +185,8 @@
     {
         final Object[] result = new Object[1];
         final Exception[] exception = new Exception[1];
-        runInUISync(new Runnable() {
+        runInUISync(new Runnable()
+        {
             public void run()
             {
                 try
@@ -209,50 +198,49 @@
                     exception[0] = e;
                 }
             }
-            
+
         });
-        if ( exception[0] == null ) {
+        if (exception[0] == null)
+        {
             return (T) result[0];
         }
-        else {
+        else
+        {
             throw exception[0];
         }
     }
 
-
-    public static void runInUISync( Runnable runnable )
+    public static void runInUISync(Runnable runnable)
     {
-        getActiveDisplay().syncExec( runnable );
+        getActiveDisplay().syncExec(runnable);
     }
 
-
-    public static Image cacheImage( String path, ClassLoader classLoader )
+    public static Image cacheImage(String path, ClassLoader classLoader)
     {
         ImageRegistry registry = SigilUI.getDefault().getImageRegistry();
 
-        Image image = registry.get( path );
+        Image image = registry.get(path);
 
-        if ( image == null )
+        if (image == null)
         {
-            image = loadImage( path, classLoader );
+            image = loadImage(path, classLoader);
             // XXX-FIXME-XXX add null image
-            if ( image != null )
+            if (image != null)
             {
-                registry.put( path, image );
+                registry.put(path, image);
             }
         }
 
         return image;
     }
 
-
-    private static Image loadImage( String resource, ClassLoader loader )
+    private static Image loadImage(String resource, ClassLoader loader)
     {
-        InputStream in = loader.getResourceAsStream( resource );
-        if ( in != null )
+        InputStream in = loader.getResourceAsStream(resource);
+        if (in != null)
         {
-            ImageData data = new ImageData( in );
-            return new Image( SigilUI.getActiveDisplay(), data );
+            ImageData data = new ImageData(in);
+            return new Image(SigilUI.getActiveDisplay(), data);
         }
         else
         {
@@ -260,5 +248,4 @@
         }
     }
 
-
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/DisplayAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/DisplayAction.java
index 36ceb93..e40b86d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/DisplayAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/DisplayAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.actions;
 
-
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -27,7 +26,6 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 
-
 public abstract class DisplayAction extends Action
 {
 
@@ -36,30 +34,26 @@
         super();
     }
 
-
-    public DisplayAction( String text )
+    public DisplayAction(String text)
     {
-        super( text );
+        super(text);
     }
 
-
-    public DisplayAction( String text, ImageDescriptor image )
+    public DisplayAction(String text, ImageDescriptor image)
     {
-        super( text, image );
+        super(text, image);
     }
 
-
-    public DisplayAction( String text, int style )
+    public DisplayAction(String text, int style)
     {
-        super( text, style );
+        super(text, style);
     }
 
-
     protected Display findDisplay()
     {
         Display d = Display.getCurrent();
 
-        if ( d == null )
+        if (d == null)
         {
             d = Display.getDefault();
         }
@@ -67,21 +61,19 @@
         return d;
     }
 
-
-    protected void runInUI( final Shell shell, final WorkspaceModifyOperation op )
+    protected void runInUI(final Shell shell, final WorkspaceModifyOperation op)
     {
     }
 
-
-    protected void info( final Shell shell, final String msg )
+    protected void info(final Shell shell, final String msg)
     {
-        shell.getDisplay().asyncExec( new Runnable()
+        shell.getDisplay().asyncExec(new Runnable()
         {
             public void run()
             {
-                MessageDialog.openInformation( shell, "Information", msg );
+                MessageDialog.openInformation(shell, "Information", msg);
             }
-        } );
+        });
     }
 
 }
\ No newline at end of file
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/PruneProjectDependenciesAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/PruneProjectDependenciesAction.java
index 29535b5..d3715c0 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/PruneProjectDependenciesAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/PruneProjectDependenciesAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.actions;
 
-
 import java.util.Collection;
 
 import org.apache.felix.sigil.common.model.IModelElement;
@@ -39,68 +38,68 @@
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 import org.eclipse.ui.progress.IProgressService;
 
-
 public class PruneProjectDependenciesAction extends DisplayAction
 {
 
     private ISigilProjectModel project;
 
-
-    public PruneProjectDependenciesAction( ISigilProjectModel project )
+    public PruneProjectDependenciesAction(ISigilProjectModel project)
     {
         this.project = project;
     }
 
-
     @Override
     public void run()
     {
         final Shell shell = findDisplay().getActiveShell();
 
-        Job job = new Job( "Resolving imports" )
+        Job job = new Job("Resolving imports")
         {
 
             @Override
-            protected IStatus run( IProgressMonitor monitor )
+            protected IStatus run(IProgressMonitor monitor)
             {
-                Collection<IModelElement> unused = JavaHelper.findUnusedReferences( project, monitor );
+                Collection<IModelElement> unused = JavaHelper.findUnusedReferences(
+                    project, monitor);
 
-                if ( unused.isEmpty() )
+                if (unused.isEmpty())
                 {
-                    info( shell, "No unused references found" );
+                    info(shell, "No unused references found");
                 }
                 else
                 {
-                    final ResourceReviewDialog<IModelElement> dialog = new ResourceReviewDialog<IModelElement>( shell,
-                        "Review Unused Imports", unused );
+                    final ResourceReviewDialog<IModelElement> dialog = new ResourceReviewDialog<IModelElement>(
+                        shell, "Review Unused Imports", unused);
 
-                    shell.getDisplay().asyncExec( new Runnable()
+                    shell.getDisplay().asyncExec(new Runnable()
                     {
                         public void run()
                         {
-                            if ( dialog.open() == Window.OK )
+                            if (dialog.open() == Window.OK)
                             {
                                 WorkspaceModifyOperation op = new WorkspaceModifyOperation()
                                 {
                                     @Override
-                                    protected void execute( IProgressMonitor monitor ) throws CoreException
+                                    protected void execute(IProgressMonitor monitor)
+                                        throws CoreException
                                     {
-                                        for ( IModelElement e : dialog.getResources() )
+                                        for (IModelElement e : dialog.getResources())
                                         {
-                                            if ( !project.getBundle().getBundleInfo().removeChild( e ) )
+                                            if (!project.getBundle().getBundleInfo().removeChild(
+                                                e))
                                             {
-                                                SigilCore.error( "Failed to remove " + e );
+                                                SigilCore.error("Failed to remove " + e);
                                             }
                                         }
 
-                                        project.save( monitor );
+                                        project.save(monitor);
                                     }
                                 };
 
-                                SigilUI.runWorkspaceOperation( op, shell );
+                                SigilUI.runWorkspaceOperation(op, shell);
                             }
                         }
-                    } );
+                    });
                 }
 
                 return Status.OK_STATUS;
@@ -110,6 +109,6 @@
         job.schedule();
 
         IProgressService p = PlatformUI.getWorkbench().getProgressService();
-        p.showInDialog( shell, job );
+        p.showInDialog(shell, job);
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
index 54be687..c737c2f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.actions;
 
-
 import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 
@@ -33,19 +32,16 @@
 import org.eclipse.core.runtime.SubMonitor;
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 
-
 public class RefreshRepositoryAction extends DisplayAction
 {
     private final IRepositoryModel[] model;
 
-
-    public RefreshRepositoryAction( IRepositoryModel... model )
+    public RefreshRepositoryAction(IRepositoryModel... model)
     {
-        super( "Refresh repository" );
+        super("Refresh repository");
         this.model = model;
     }
 
-
     @Override
     public void run()
     {
@@ -53,16 +49,16 @@
         {
 
             @Override
-            protected void execute( IProgressMonitor monitor ) throws CoreException, InvocationTargetException,
-                InterruptedException
+            protected void execute(IProgressMonitor monitor) throws CoreException,
+                InvocationTargetException, InterruptedException
             {
                 boolean changed = false;
 
-                for ( IBundleRepository b : SigilCore.getGlobalRepositoryManager().getRepositories() )
+                for (IBundleRepository b : SigilCore.getGlobalRepositoryManager().getRepositories())
                 {
-                    for ( IRepositoryModel m : model )
+                    for (IRepositoryModel m : model)
                     {
-                        if ( b.getId().equals( m.getId() ) )
+                        if (b.getId().equals(m.getId()))
                         {
                             b.refresh();
                             changed = true;
@@ -70,18 +66,18 @@
                     }
                 }
 
-                if ( changed )
+                if (changed)
                 {
                     List<ISigilProjectModel> projects = SigilCore.getRoot().getProjects();
-                    SubMonitor sub = SubMonitor.convert( monitor, projects.size() * 10 );
-                    for ( ISigilProjectModel p : projects )
+                    SubMonitor sub = SubMonitor.convert(monitor, projects.size() * 10);
+                    for (ISigilProjectModel p : projects)
                     {
-                        p.resetClasspath( sub.newChild( 10 ) );
+                        p.resetClasspath(sub.newChild(10));
                     }
                 }
             }
         };
 
-        SigilUI.runWorkspaceOperation( op, null );
+        SigilUI.runWorkspaceOperation(op, null);
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/ResolveProjectDependenciesAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/ResolveProjectDependenciesAction.java
index 9f1ed6e..413281e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/ResolveProjectDependenciesAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/ResolveProjectDependenciesAction.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.actions;
 
-
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
@@ -40,83 +39,84 @@
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 import org.eclipse.ui.progress.IProgressService;
 
-
 public class ResolveProjectDependenciesAction extends DisplayAction
 {
 
     private ISigilProjectModel project;
     private boolean review;
 
-
-    public ResolveProjectDependenciesAction( ISigilProjectModel project, boolean review )
+    public ResolveProjectDependenciesAction(ISigilProjectModel project, boolean review)
     {
         this.project = project;
         this.review = review;
     }
 
-
     public void run()
     {
         final Shell shell = findDisplay().getActiveShell();
 
-        Job job = new Job( "Resolving dependencies" )
+        Job job = new Job("Resolving dependencies")
         {
             @Override
-            protected IStatus run( IProgressMonitor monitor )
+            protected IStatus run(IProgressMonitor monitor)
             {
-                monitor.beginTask( "", IProgressMonitor.UNKNOWN );
+                monitor.beginTask("", IProgressMonitor.UNKNOWN);
 
-                List<IPackageImport> imports = JavaHelper.findRequiredImports( project, monitor );
+                List<IPackageImport> imports = JavaHelper.findRequiredImports(project,
+                    monitor);
 
-                if ( imports.isEmpty() )
+                if (imports.isEmpty())
                 {
-                    info( shell, "No new dependencies found" );
+                    info(shell, "No new dependencies found");
                 }
                 else
                 {
-                    Collections.sort( imports, new Comparator<IPackageImport>()
+                    Collections.sort(imports, new Comparator<IPackageImport>()
                     {
-                        public int compare( IPackageImport o1, IPackageImport o2 )
+                        public int compare(IPackageImport o1, IPackageImport o2)
                         {
-                            int i = o1.getPackageName().compareTo( o2.getPackageName() );
+                            int i = o1.getPackageName().compareTo(o2.getPackageName());
 
                             // shouldn't get more than one import for same package
                             // but may as well sort if do...
-                            if ( i == 0 )
+                            if (i == 0)
                             {
-                                i = o1.getVersions().getFloor().compareTo( o2.getVersions().getFloor() );
+                                i = o1.getVersions().getFloor().compareTo(
+                                    o2.getVersions().getFloor());
                             }
 
                             return i;
                         }
-                    } );
+                    });
 
                     final ResourceReviewDialog<IPackageImport> dialog = new ResourceReviewDialog<IPackageImport>(
-                        shell, "Review New Dependencies", imports );
-                    shell.getDisplay().asyncExec( new Runnable()
+                        shell, "Review New Dependencies", imports);
+                    shell.getDisplay().asyncExec(new Runnable()
                     {
                         public void run()
                         {
-                            if ( !review || dialog.open() == Window.OK )
+                            if (!review || dialog.open() == Window.OK)
                             {
                                 WorkspaceModifyOperation op = new WorkspaceModifyOperation()
                                 {
                                     @Override
-                                    protected void execute( IProgressMonitor monitor ) throws CoreException
+                                    protected void execute(IProgressMonitor monitor)
+                                        throws CoreException
                                     {
-                                        for ( IPackageImport pi : dialog.getResources() )
+                                        for (IPackageImport pi : dialog.getResources())
                                         {
-                                            project.getBundle().getBundleInfo().addImport( pi );
+                                            project.getBundle().getBundleInfo().addImport(
+                                                pi);
                                         }
 
-                                        project.save( monitor );
+                                        project.save(monitor);
                                     }
                                 };
 
-                                SigilUI.runWorkspaceOperation( op, shell );
+                                SigilUI.runWorkspaceOperation(op, shell);
                             }
                         }
-                    } );
+                    });
                 }
 
                 return Status.OK_STATUS;
@@ -126,7 +126,7 @@
         job.schedule();
 
         IProgressService p = PlatformUI.getWorkbench().getProgressService();
-        p.showInDialog( shell, job );
+        p.showInDialog(shell, job);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClassPathContainer.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClassPathContainer.java
index 236dbbd..3edab69 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClassPathContainer.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClassPathContainer.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.classpath;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.job.ThreadProgressMonitor;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
@@ -30,7 +29,6 @@
 import org.eclipse.jdt.core.IClasspathContainer;
 import org.eclipse.jdt.core.IClasspathEntry;
 
-
 /**
  * @author dave
  *
@@ -41,19 +39,17 @@
     private IClasspathEntry[] entries;
     private ISigilProjectModel sigil;
 
-
-    public SigilClassPathContainer( ISigilProjectModel sigil )
+    public SigilClassPathContainer(ISigilProjectModel sigil)
     {
         this.sigil = sigil;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries()
      */
     public IClasspathEntry[] getClasspathEntries()
     {
-        if ( entries == null )
+        if (entries == null)
         {
             buildClassPathEntries();
         }
@@ -61,7 +57,6 @@
         return entries;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
      */
@@ -70,7 +65,6 @@
         return "Bundle Context Classpath";
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jdt.core.IClasspathContainer#getKind()
      */
@@ -79,16 +73,14 @@
         return K_SYSTEM;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jdt.core.IClasspathContainer#getPath()
      */
     public IPath getPath()
     {
-        return new Path( SigilCore.CLASSPATH_CONTAINER_PATH );
+        return new Path(SigilCore.CLASSPATH_CONTAINER_PATH);
     }
 
-
     /**
      * @return
      * @throws CoreException 
@@ -99,18 +91,17 @@
         try
         {
             IProgressMonitor monitor = ThreadProgressMonitor.getProgressMonitor();
-            entries = sigil.findExternalClasspath( monitor ).toArray( new IClasspathEntry[0] );
+            entries = sigil.findExternalClasspath(monitor).toArray(new IClasspathEntry[0]);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to build classpath entries", e );
+            SigilCore.error("Failed to build classpath entries", e);
         }
         finally
         {
-            if ( entries == null )
+            if (entries == null)
             {
-                entries = new IClasspathEntry[]
-                    {};
+                entries = new IClasspathEntry[] {};
             }
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClasspathContainerInitializer.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClasspathContainerInitializer.java
index 03f196f..46e66b5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClasspathContainerInitializer.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClasspathContainerInitializer.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.classpath;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.job.*;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
@@ -32,7 +31,6 @@
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
 
-
 public class SigilClasspathContainerInitializer extends ClasspathContainerInitializer
 {
 
@@ -41,55 +39,52 @@
         // TODO Auto-generated constructor stub
     }
 
-
     @Override
-    public boolean canUpdateClasspathContainer( IPath containerPath, IJavaProject project )
+    public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project)
     {
         return true;
     }
 
-
     @Override
-    public void requestClasspathContainerUpdate( IPath containerPath, IJavaProject project,
-        IClasspathContainer containerSuggestion ) throws CoreException
+    public void requestClasspathContainerUpdate(IPath containerPath,
+        IJavaProject project, IClasspathContainer containerSuggestion)
+        throws CoreException
     {
-        ISigilProjectModel sigil = SigilCore.create( project.getProject() );
+        ISigilProjectModel sigil = SigilCore.create(project.getProject());
 
-        IClasspathContainer sigilContainer = new SigilClassPathContainer( sigil );
+        IClasspathContainer sigilContainer = new SigilClassPathContainer(sigil);
 
-        IJavaProject[] affectedProjects = new IJavaProject[]
-            { project };
+        IJavaProject[] affectedProjects = new IJavaProject[] { project };
 
-        IClasspathContainer[] respectiveContainers = new IClasspathContainer[]
-            { sigilContainer };
+        IClasspathContainer[] respectiveContainers = new IClasspathContainer[] { sigilContainer };
 
         IProgressMonitor monitor = ThreadProgressMonitor.getProgressMonitor();
 
-        if ( monitor == null )
+        if (monitor == null)
         {
             monitor = Job.getJobManager().createProgressGroup();
         }
 
-        JavaCore.setClasspathContainer( containerPath, affectedProjects, respectiveContainers, monitor );
+        JavaCore.setClasspathContainer(containerPath, affectedProjects,
+            respectiveContainers, monitor);
     }
 
-
     @Override
-    public void initialize( IPath containerPath, IJavaProject project ) throws CoreException
+    public void initialize(IPath containerPath, IJavaProject project)
+        throws CoreException
     {
-        ISigilProjectModel sigil = SigilCore.create( project.getProject() );
+        ISigilProjectModel sigil = SigilCore.create(project.getProject());
 
-        IClasspathContainer sigilContainer = new SigilClassPathContainer( sigil );
+        IClasspathContainer sigilContainer = new SigilClassPathContainer(sigil);
 
-        IJavaProject[] affectedProjects = new IJavaProject[]
-            { project };
+        IJavaProject[] affectedProjects = new IJavaProject[] { project };
 
-        IClasspathContainer[] respectiveContainers = new IClasspathContainer[]
-            { sigilContainer };
+        IClasspathContainer[] respectiveContainers = new IClasspathContainer[] { sigilContainer };
 
         IProgressMonitor monitor = Job.getJobManager().createProgressGroup();
 
-        JavaCore.setClasspathContainer( containerPath, affectedProjects, respectiveContainers, monitor );
+        JavaCore.setClasspathContainer(containerPath, affectedProjects,
+            respectiveContainers, monitor);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilLibraryPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilLibraryPage.java
index c18ec50..1fa13fd 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilLibraryPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilLibraryPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.classpath;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jdt.core.IClasspathEntry;
@@ -30,51 +29,45 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 
-
 public class SigilLibraryPage extends WizardPage implements IClasspathContainerPage
 {
 
     private IClasspathEntry classpathEntry;
 
-
     public SigilLibraryPage()
     {
-        super( "Sigil" );
+        super("Sigil");
     }
 
-
-    public void createControl( Composite parent )
+    public void createControl(Composite parent)
     {
-        setTitle( "Sigil Library" );
+        setTitle("Sigil Library");
 
-        Label label = new Label( parent, SWT.NONE );
-        label.setText( "Press Finish to add the Sigil Library" );
-        label.setFont( parent.getFont() );
+        Label label = new Label(parent, SWT.NONE);
+        label.setText("Press Finish to add the Sigil Library");
+        label.setFont(parent.getFont());
 
-        setControl( label );
+        setControl(label);
     }
 
-
     public boolean finish()
     {
-        classpathEntry = JavaCore.newContainerEntry( new Path( SigilCore.CLASSPATH_CONTAINER_PATH ) );
+        classpathEntry = JavaCore.newContainerEntry(new Path(
+            SigilCore.CLASSPATH_CONTAINER_PATH));
         return true;
     }
 
-
     public boolean isPageComplete()
     {
         return true;
     }
 
-
     public IClasspathEntry getSelection()
     {
         return classpathEntry;
     }
 
-
-    public void setSelection( IClasspathEntry containerEntry )
+    public void setSelection(IClasspathEntry containerEntry)
     {
         this.classpathEntry = containerEntry;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/completion/CompletionProposal.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/completion/CompletionProposal.java
index 460e27f..b74ea93 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/completion/CompletionProposal.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/completion/CompletionProposal.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.completion;
 
-
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.contentassist.ICompletionProposal;
@@ -27,7 +26,6 @@
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 
-
 class CompletionProposal implements ICompletionProposal
 {
 
@@ -40,7 +38,6 @@
     private String fDisplayString;
     private Image fImage;
 
-
     /**
      * Creates a new completion proposal based on the provided information. The replacement string is
      * considered being the display string too. All remaining fields are set to <code>null</code>.
@@ -50,13 +47,12 @@
      * @param replacementLength the length of the text to be replaced
      * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
      */
-    public CompletionProposal( String replacementString, int replacementOffset, int replacementLength,
-        int cursorPosition )
+    public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition)
     {
-        this( replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null );
+        this(replacementString, replacementOffset, replacementLength, cursorPosition,
+            null, null, null, null);
     }
 
-
     /**
      * Creates a new completion proposal. All fields are initialized based on the provided information.
      *
@@ -69,9 +65,7 @@
      * @param contextInformation the context information associated with this proposal
      * @param additionalProposalInfo the additional information associated with this proposal
      */
-    public CompletionProposal( String replacementString, int replacementOffset, int replacementLength,
-        int cursorPosition, Image image, String displayString, IContextInformation contextInformation,
-        String additionalProposalInfo )
+    public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo)
     {
         fReplacementString = replacementString;
         fReplacementOffset = replacementOffset;
@@ -83,23 +77,21 @@
         fAdditionalProposalInfo = additionalProposalInfo;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
      */
-    public void apply( IDocument document )
+    public void apply(IDocument document)
     {
         try
         {
-            document.replace( fReplacementOffset, fReplacementLength, fReplacementString );
+            document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
         }
-        catch ( BadLocationException x )
+        catch (BadLocationException x)
         {
             // ignore
         }
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
      */
@@ -108,7 +100,6 @@
         return fAdditionalProposalInfo;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
      */
@@ -117,18 +108,16 @@
         return fContextInformation;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
      */
     public String getDisplayString()
     {
-        if ( fDisplayString != null )
+        if (fDisplayString != null)
             return fDisplayString;
         return fReplacementString;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
      */
@@ -137,13 +126,12 @@
         return fImage;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
      */
-    public Point getSelection( IDocument document )
+    public Point getSelection(IDocument document)
     {
-        return new Point( fReplacementOffset + fCursorPosition, 0 );
+        return new Point(fReplacementOffset + fCursorPosition, 0);
     }
 
 }
\ No newline at end of file
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/AbstractResourceSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/AbstractResourceSection.java
index abd4ad8..6fb8ee1 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/AbstractResourceSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/AbstractResourceSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.io.File;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
@@ -43,35 +42,29 @@
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.ui.forms.IManagedForm;
 
-
-public abstract class AbstractResourceSection extends SigilSection implements IResourceChangeListener,
-    ICheckStateListener
+public abstract class AbstractResourceSection extends SigilSection implements IResourceChangeListener, ICheckStateListener
 {
 
-    protected static final Object[] EMPTY = new Object[]
-        {};
+    protected static final Object[] EMPTY = new Object[] {};
     protected Tree tree;
     protected CheckboxTreeViewer viewer;
     private IWorkspace workspace;
 
-
-    public AbstractResourceSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public AbstractResourceSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
     @Override
-    public void initialize( IManagedForm form )
+    public void initialize(IManagedForm form)
     {
-        super.initialize( form );
-        viewer.setAllChecked( false );
-        viewer.setGrayedElements( EMPTY );
+        super.initialize(form);
+        viewer.setAllChecked(false);
+        viewer.setGrayedElements(EMPTY);
         refreshSelections();
         viewer.refresh();
     }
 
-
     @Override
     public void refresh()
     {
@@ -79,145 +72,137 @@
         super.refresh();
     }
 
-
-    public void checkStateChanged( CheckStateChangedEvent event )
+    public void checkStateChanged(CheckStateChangedEvent event)
     {
-        handleStateChanged( ( IResource ) event.getElement(), event.getChecked(), true, true );
+        handleStateChanged((IResource) event.getElement(), event.getChecked(), true, true);
     }
 
-
-    public void resourceChanged( IResourceChangeEvent event )
+    public void resourceChanged(IResourceChangeEvent event)
     {
-        if ( !getSection().getDisplay().isDisposed() )
+        if (!getSection().getDisplay().isDisposed())
         {
-            getSection().getDisplay().asyncExec( new Runnable()
+            getSection().getDisplay().asyncExec(new Runnable()
             {
                 public void run()
                 {
-                    if ( getSection().isVisible() )
+                    if (getSection().isVisible())
                     {
                         viewer.refresh();
                     }
                 }
-            } );
+            });
         }
     }
 
-
-    protected void startWorkspaceListener( IWorkspace workspace )
+    protected void startWorkspaceListener(IWorkspace workspace)
     {
         this.workspace = workspace;
-        workspace.addResourceChangeListener( this );
+        workspace.addResourceChangeListener(this);
     }
 
-
     @Override
     public void dispose()
     {
-        workspace.removeResourceChangeListener( this );
+        workspace.removeResourceChangeListener(this);
     }
 
-
     protected abstract void refreshSelections();
 
+    protected abstract void syncResourceModel(IResource element, boolean checked);
 
-    protected abstract void syncResourceModel( IResource element, boolean checked );
-
-
-    protected IResource findResource( IPath path )
+    protected IResource findResource(IPath path)
     {
         IProject project2 = getProjectModel().getProject();
-        File f = project2.getLocation().append( path ).toFile();
+        File f = project2.getLocation().append(path).toFile();
 
-        if ( f.exists() )
+        if (f.exists())
         {
             try
             {
-                if ( f.isFile() )
+                if (f.isFile())
                 {
-                    return project2.getFile( path );
+                    return project2.getFile(path);
                 }
                 else
                 {
-                    return project2.getFolder( path );
+                    return project2.getFolder(path);
                 }
             }
-            catch ( IllegalArgumentException e )
+            catch (IllegalArgumentException e)
             {
-                SigilCore.error( "Unknown path " + path );
+                SigilCore.error("Unknown path " + path);
                 return null;
             }
         }
         else
         {
-            SigilCore.error( "Unknown file " + f );
+            SigilCore.error("Unknown file " + f);
             return null;
         }
     }
 
-
-    protected void handleStateChanged( IResource element, boolean checked, boolean recurse, boolean sync )
+    protected void handleStateChanged(IResource element, boolean checked,
+        boolean recurse, boolean sync)
     {
-        if ( element instanceof IContainer )
+        if (element instanceof IContainer)
         {
-            setParentsGrayChecked( element, checked );
-            if ( recurse )
+            setParentsGrayChecked(element, checked);
+            if (recurse)
             {
-                recursiveCheck( ( IContainer ) element, checked, sync );
+                recursiveCheck((IContainer) element, checked, sync);
             }
         }
         else
         {
-            setParentsGrayChecked( element, checked );
+            setParentsGrayChecked(element, checked);
         }
 
-        if ( sync )
+        if (sync)
         {
-            syncResourceModel( element, checked );
+            syncResourceModel(element, checked);
         }
     }
 
-
-    private void recursiveCheck( IContainer element, final boolean checked, final boolean sync )
+    private void recursiveCheck(IContainer element, final boolean checked,
+        final boolean sync)
     {
         try
         {
-            element.accept( new IResourceVisitor()
+            element.accept(new IResourceVisitor()
             {
-                public boolean visit( IResource resource ) throws CoreException
+                public boolean visit(IResource resource) throws CoreException
                 {
-                    viewer.setChecked( resource, checked );
-                    if ( sync )
+                    viewer.setChecked(resource, checked);
+                    if (sync)
                     {
-                        syncResourceModel( resource, checked );
+                        syncResourceModel(resource, checked);
                     }
                     return true;
                 }
-            } );
+            });
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            DebugPlugin.log( e.getStatus() );
+            DebugPlugin.log(e.getStatus());
         }
     }
 
-
-    private void setParentsGrayChecked( IResource r, boolean checked )
+    private void setParentsGrayChecked(IResource r, boolean checked)
     {
-        while ( r.getParent() != null )
+        while (r.getParent() != null)
         {
             r = r.getParent();
-            if ( ( viewer.getGrayed( r ) && viewer.getChecked( r ) ) == checked )
+            if ((viewer.getGrayed(r) && viewer.getChecked(r)) == checked)
             {
                 break;
             }
-            if ( viewer.getChecked( r ) == checked )
+            if (viewer.getChecked(r) == checked)
             {
-                viewer.setGrayed( r, !checked );
+                viewer.setGrayed(r, !checked);
             }
             else
             {
-                viewer.setGrayChecked( r, checked );
+                viewer.setGrayChecked(r, checked);
             }
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/BundleDependencySection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/BundleDependencySection.java
index 6ef63ba..76e298a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/BundleDependencySection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/BundleDependencySection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.Set;
 
 import org.apache.felix.sigil.common.model.IModelElement;
@@ -44,7 +43,6 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-
 public abstract class BundleDependencySection extends SigilSection
 {
 
@@ -53,39 +51,29 @@
     private Button edit;
     private Button remove;
 
-
-    public BundleDependencySection( SigilPage page, Composite parent, ISigilProjectModel project,
-        Set<IModelElement> unresolvedElements ) throws CoreException
+    public BundleDependencySection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedElements) throws CoreException
     {
-        super( page, parent, project );
-        viewer.setUnresolvedElements( unresolvedElements );
+        super(page, parent, project);
+        viewer.setUnresolvedElements(unresolvedElements);
     }
 
-
-    public BundleDependencySection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public BundleDependencySection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        this( page, parent, project, null );
+        this(page, parent, project, null);
     }
 
-
     protected abstract String getTitle();
 
-
-    protected abstract Label createLabel( Composite parent, FormToolkit toolkit );
-
+    protected abstract Label createLabel(Composite parent, FormToolkit toolkit);
 
     protected abstract IContentProvider getContentProvider();
 
-
     protected abstract void handleAdd();
 
-
     protected abstract void handleEdit();
 
-
     protected abstract void handleRemoved();
 
-
     @Override
     public void refresh()
     {
@@ -93,100 +81,96 @@
         viewer.refresh();
     }
 
-
     protected ISelection getSelection()
     {
         return viewer.getSelection();
     }
 
-
     @Override
-    protected void createSection( Section section, FormToolkit toolkit )
+    protected void createSection(Section section, FormToolkit toolkit)
     {
-        setTitle( getTitle() );
+        setTitle(getTitle());
 
-        Composite body = createGridBody( 2, false, toolkit );
+        Composite body = createGridBody(2, false, toolkit);
 
-        Label label = createLabel( body, toolkit );
+        Label label = createLabel(body, toolkit);
 
-        label.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, true, true, 2, 1 ) );
+        label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1));
 
-        Table bundleTable = toolkit.createTable( body, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.BORDER );
-        GridData data = new GridData( GridData.FILL_BOTH );
+        Table bundleTable = toolkit.createTable(body, SWT.MULTI | SWT.FULL_SELECTION
+            | SWT.VIRTUAL | SWT.BORDER);
+        GridData data = new GridData(GridData.FILL_BOTH);
         data.heightHint = 600;
-        bundleTable.setLayoutData( data );
-        bundleTable.setLinesVisible( false );
-        createButtons( body, toolkit );
-        createViewer( bundleTable );
+        bundleTable.setLayoutData(data);
+        bundleTable.setLinesVisible(false);
+        createButtons(body, toolkit);
+        createViewer(bundleTable);
     }
 
-
-    protected void createButtons( Composite body, FormToolkit toolkit )
+    protected void createButtons(Composite body, FormToolkit toolkit)
     {
-        Composite buttons = toolkit.createComposite( body );
+        Composite buttons = toolkit.createComposite(body);
         TableWrapLayout layout = new TableWrapLayout();
         layout.numColumns = 1;
         layout.topMargin = 0;
         layout.leftMargin = 0;
         layout.rightMargin = 0;
         layout.bottomMargin = 0;
-        buttons.setLayout( layout );
+        buttons.setLayout(layout);
         GridData data = new GridData();
         data.verticalAlignment = SWT.TOP;
-        buttons.setLayoutData( data );
+        buttons.setLayoutData(data);
 
-        add = toolkit.createButton( buttons, "Add", SWT.NULL );
-        add.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
-        add.addSelectionListener( new SelectionAdapter()
+        add = toolkit.createButton(buttons, "Add", SWT.NULL);
+        add.setLayoutData(new TableWrapData(TableWrapData.FILL));
+        add.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleAdd();
             }
-        } );
+        });
 
-        edit = toolkit.createButton( buttons, "Edit", SWT.NULL );
-        edit.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
-        edit.addSelectionListener( new SelectionAdapter()
+        edit = toolkit.createButton(buttons, "Edit", SWT.NULL);
+        edit.setLayoutData(new TableWrapData(TableWrapData.FILL));
+        edit.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleEdit();
             }
-        } );
+        });
 
-        remove = toolkit.createButton( buttons, "Remove", SWT.NULL );
-        remove.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
-        remove.addSelectionListener( new SelectionAdapter()
+        remove = toolkit.createButton(buttons, "Remove", SWT.NULL);
+        remove.setLayoutData(new TableWrapData(TableWrapData.FILL));
+        remove.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleRemoved();
             }
-        } );
+        });
 
-        setSelected( false );
+        setSelected(false);
     }
 
-
-    protected void createViewer( Table bundleTable )
+    protected void createViewer(Table bundleTable)
     {
-        viewer = new ProjectTableViewer( bundleTable );
-        viewer.setContentProvider( getContentProvider() );
-        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        viewer = new ProjectTableViewer(bundleTable);
+        viewer.setContentProvider(getContentProvider());
+        viewer.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
-                setSelected( !event.getSelection().isEmpty() );
+                setSelected(!event.getSelection().isEmpty());
             }
-        } );
+        });
     }
 
-
-    private void setSelected( boolean selected )
+    private void setSelected(boolean selected)
     {
-        edit.setEnabled( selected );
-        remove.setEnabled( selected );
+        edit.setEnabled(selected);
+        remove.setEnabled(selected);
     }
 
 }
\ No newline at end of file
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ClasspathSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ClasspathSection.java
index 2086a3c..6261f21 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ClasspathSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ClasspathSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -57,196 +56,189 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-
 public class ClasspathSection extends SigilSection
 {
 
     private ProjectTableViewer viewer;
     private final Comparator<IClasspathEntry> CLASSPATH_COMPARATOR = new Comparator<IClasspathEntry>()
     {
-        public int compare( IClasspathEntry o1, IClasspathEntry o2 )
+        public int compare(IClasspathEntry o1, IClasspathEntry o2)
         {
-            return compareClasspaths( o1, o2 );
+            return compareClasspaths(o1, o2);
         }
     };
 
-
-    public ClasspathSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public ClasspathSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
     @Override
-    protected void createSection( Section section, FormToolkit toolkit )
+    protected void createSection(Section section, FormToolkit toolkit)
     {
-        setTitle( "Classpath" );
+        setTitle("Classpath");
 
-        Composite body = createGridBody( 2, false, toolkit );
+        Composite body = createGridBody(2, false, toolkit);
 
-        Label label = toolkit.createLabel( body, "Specify the internal classpath of this bundle." );
-        label.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, true, true, 2, 1 ) );
+        Label label = toolkit.createLabel(body,
+            "Specify the internal classpath of this bundle.");
+        label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1));
 
-        Table bundleTable = toolkit.createTable( body, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.BORDER );
-        GridData tableLayoutData = new GridData( SWT.FILL, SWT.FILL, true, true );
+        Table bundleTable = toolkit.createTable(body, SWT.MULTI | SWT.FULL_SELECTION
+            | SWT.VIRTUAL | SWT.BORDER);
+        GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
         tableLayoutData.heightHint = 150;
-        bundleTable.setLayoutData( tableLayoutData );
+        bundleTable.setLayoutData(tableLayoutData);
 
-        createButtons( body, toolkit );
-        createViewer( bundleTable );
+        createButtons(body, toolkit);
+        createViewer(bundleTable);
     }
 
-
-    private void createButtons( Composite body, FormToolkit toolkit )
+    private void createButtons(Composite body, FormToolkit toolkit)
     {
-        Composite buttons = toolkit.createComposite( body );
+        Composite buttons = toolkit.createComposite(body);
         TableWrapLayout layout = new TableWrapLayout();
         layout.numColumns = 1;
         layout.topMargin = 0;
         layout.leftMargin = 0;
         layout.rightMargin = 0;
         layout.bottomMargin = 0;
-        buttons.setLayout( layout );
+        buttons.setLayout(layout);
 
-        Button add = toolkit.createButton( buttons, "Add", SWT.NULL );
-        add.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
-        add.addSelectionListener( new SelectionAdapter()
+        Button add = toolkit.createButton(buttons, "Add", SWT.NULL);
+        add.setLayoutData(new TableWrapData(TableWrapData.FILL));
+        add.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleAdd();
             }
-        } );
+        });
 
-        Button remove = toolkit.createButton( buttons, "Remove", SWT.NULL );
-        remove.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
-        remove.addSelectionListener( new SelectionAdapter()
+        Button remove = toolkit.createButton(buttons, "Remove", SWT.NULL);
+        remove.setLayoutData(new TableWrapData(TableWrapData.FILL));
+        remove.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleRemoved();
             }
-        } );
+        });
     }
 
-
-    private void createViewer( Table bundleTable )
+    private void createViewer(Table bundleTable)
     {
-        viewer = new ProjectTableViewer( bundleTable );
-        viewer.setContentProvider( new DefaultTableProvider()
+        viewer = new ProjectTableViewer(bundleTable);
+        viewer.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
                 ArrayList<IClasspathEntry> cp = new ArrayList<IClasspathEntry>();
-                for ( IClasspathEntry cpe : JavaHelper.findClasspathEntries( getBundle() ) )
+                for (IClasspathEntry cpe : JavaHelper.findClasspathEntries(getBundle()))
                 {
-                    cp.add( cpe );
+                    cp.add(cpe);
                 }
 
-                Collections.sort( cp, new Comparator<IClasspathEntry>()
+                Collections.sort(cp, new Comparator<IClasspathEntry>()
                 {
-                    public int compare( IClasspathEntry o1, IClasspathEntry o2 )
+                    public int compare(IClasspathEntry o1, IClasspathEntry o2)
                     {
-                        return o1.toString().compareTo( o2.toString() );
+                        return o1.toString().compareTo(o2.toString());
                     }
-                } );
+                });
                 return cp.toArray();
             }
-        } );
-        viewer.setComparator( new ViewerComparator()
+        });
+        viewer.setComparator(new ViewerComparator()
         {
             @Override
-            public int category( Object element )
+            public int category(Object element)
             {
-                return index( ( IClasspathEntry ) element );
+                return index((IClasspathEntry) element);
             }
-        } );
+        });
     }
 
-
     protected ISigilBundle getBundle()
     {
         return getProjectModel().getBundle();
     }
 
-
     private void handleAdd()
     {
         try
         {
             BackgroundLoadingSelectionDialog<IClasspathEntry> dialog = new BackgroundLoadingSelectionDialog<IClasspathEntry>(
-                getSection().getShell(), "Classpath Entry:", true );
+                getSection().getShell(), "Classpath Entry:", true);
 
-            dialog.setDescriptor( new IElementDescriptor<IClasspathEntry>()
+            dialog.setDescriptor(new IElementDescriptor<IClasspathEntry>()
             {
-                public String getName( IClasspathEntry element )
+                public String getName(IClasspathEntry element)
                 {
                     return element.getPath().toString();
                 }
 
-
-                public String getLabel( IClasspathEntry element )
+                public String getLabel(IClasspathEntry element)
                 {
-                    return getName( element );
+                    return getName(element);
                 }
-            } );
+            });
 
-            dialog.setLabelProvider( new ModelLabelProvider() );
+            dialog.setLabelProvider(new ModelLabelProvider());
 
-            dialog.setFilter( new IFilter<IClasspathEntry>()
+            dialog.setFilter(new IFilter<IClasspathEntry>()
             {
-                public boolean select( IClasspathEntry cp )
+                public boolean select(IClasspathEntry cp)
                 {
-                    switch ( cp.getEntryKind() )
+                    switch (cp.getEntryKind())
                     {
                         case IClasspathEntry.CPE_LIBRARY:
                         case IClasspathEntry.CPE_VARIABLE:
                         case IClasspathEntry.CPE_SOURCE:
-                            return !getBundle().getClasspathEntrys().contains( encode( cp ) );
+                            return !getBundle().getClasspathEntrys().contains(encode(cp));
                         default:
                             return false;
                     }
                 }
-            } );
+            });
 
-            dialog.setComparator( CLASSPATH_COMPARATOR );
+            dialog.setComparator(CLASSPATH_COMPARATOR);
 
             IClasspathEntry[] classpath = getProjectModel().getJavaModel().getRawClasspath();
-            dialog.addElements( Arrays.asList( classpath ) );
-            if ( dialog.open() == Window.OK )
+            dialog.addElements(Arrays.asList(classpath));
+            if (dialog.open() == Window.OK)
             {
                 List<IClasspathEntry> selectedElements = dialog.getSelectedElements();
 
                 Object[] added = selectedElements.toArray();
-                for ( IClasspathEntry entry : selectedElements )
+                for (IClasspathEntry entry : selectedElements)
                 {
-                    getBundle().addClasspathEntry( encode( entry ) );
+                    getBundle().addClasspathEntry(encode(entry));
                 }
-                viewer.add( added );
+                viewer.add(added);
                 viewer.refresh();
                 markDirty();
             }
         }
-        catch ( JavaModelException e )
+        catch (JavaModelException e)
         {
-            ErrorDialog.openError( getSection().getShell(), "Error", null, e.getStatus() );
+            ErrorDialog.openError(getSection().getShell(), "Error", null, e.getStatus());
         }
     }
 
-
-    private int compareClasspaths( IClasspathEntry o1, IClasspathEntry o2 )
+    private int compareClasspaths(IClasspathEntry o1, IClasspathEntry o2)
     {
-        if ( o1.getEntryKind() == o2.getEntryKind() )
+        if (o1.getEntryKind() == o2.getEntryKind())
         {
             ModelLabelProvider mlp = viewer.getLabelProvider();
-            return mlp.getText( o1 ).compareTo( mlp.getText( o2 ) );
+            return mlp.getText(o1).compareTo(mlp.getText(o2));
         }
         else
         {
-            int i1 = index( o1 );
-            int i2 = index( o2 );
+            int i1 = index(o1);
+            int i2 = index(o2);
 
-            if ( i1 < i2 )
+            if (i1 < i2)
             {
                 return -1;
             }
@@ -257,10 +249,9 @@
         }
     }
 
-
-    private static int index( IClasspathEntry o1 )
+    private static int index(IClasspathEntry o1)
     {
-        switch ( o1.getEntryKind() )
+        switch (o1.getEntryKind())
         {
             case IClasspathEntry.CPE_SOURCE:
                 return 0;
@@ -273,30 +264,28 @@
             case IClasspathEntry.CPE_CONTAINER:
                 return 4;
             default:
-                throw new IllegalStateException( "Unknown classpath entry type " + o1 );
+                throw new IllegalStateException("Unknown classpath entry type " + o1);
         }
     }
 
-
-    private String encode( IClasspathEntry cp )
+    private String encode(IClasspathEntry cp)
     {
-        return getProjectModel().getJavaModel().encodeClasspathEntry( cp ).trim();
+        return getProjectModel().getJavaModel().encodeClasspathEntry(cp).trim();
     }
 
-
     @SuppressWarnings("unchecked")
     private void handleRemoved()
     {
-        IStructuredSelection selection = ( IStructuredSelection ) viewer.getSelection();
+        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
 
-        if ( !selection.isEmpty() )
+        if (!selection.isEmpty())
         {
-            for ( Iterator<IClasspathEntry> i = selection.iterator(); i.hasNext(); )
+            for (Iterator<IClasspathEntry> i = selection.iterator(); i.hasNext();)
             {
                 getBundle().removeClasspathEntry(
-                    getProjectModel().getJavaModel().encodeClasspathEntry( i.next() ).trim() );
+                    getProjectModel().getJavaModel().encodeClasspathEntry(i.next()).trim());
             }
-            viewer.remove( selection.toArray() );
+            viewer.remove(selection.toArray());
             markDirty();
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentSummarySection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentSummarySection.java
index a2a3e4b..f0eedf4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentSummarySection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentSummarySection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
 import org.apache.felix.sigil.eclipse.ui.internal.form.SigilSection;
@@ -31,42 +30,40 @@
 import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.Section;
 
-
 public class ContentSummarySection extends SigilSection
 {
 
-    public ContentSummarySection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public ContentSummarySection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
     @Override
-    protected void createSection( Section section, FormToolkit toolkit )
+    protected void createSection(Section section, FormToolkit toolkit)
     {
-        setTitle( "Project Content" );
+        setTitle("Project Content");
 
-        Composite body = createTableWrapBody( 2, toolkit );
-        Hyperlink link = toolkit.createHyperlink( body, "Contents:", SWT.NONE );
-        link.setHref( ContentsForm.PAGE_ID );
-        link.addHyperlinkListener( this );
-        toolkit.createLabel( body, "Manage the content that this bundle provides." );
+        Composite body = createTableWrapBody(2, toolkit);
+        Hyperlink link = toolkit.createHyperlink(body, "Contents:", SWT.NONE);
+        link.setHref(ContentsForm.PAGE_ID);
+        link.addHyperlinkListener(this);
+        toolkit.createLabel(body, "Manage the content that this bundle provides.");
 
-        link = toolkit.createHyperlink( body, "Dependencies:", SWT.NONE );
-        link.setHref( DependenciesForm.PAGE_ID );
-        link.addHyperlinkListener( this );
-        toolkit.createLabel( body, "Manage the dependencies that this bundle needs to run." );
+        link = toolkit.createHyperlink(body, "Dependencies:", SWT.NONE);
+        link.setHref(DependenciesForm.PAGE_ID);
+        link.addHyperlinkListener(this);
+        toolkit.createLabel(body,
+            "Manage the dependencies that this bundle needs to run.");
 
-        link = toolkit.createHyperlink( body, "Exports:", SWT.NONE );
-        link.setHref( ExportsForm.PAGE_ID );
-        link.addHyperlinkListener( this );
-        toolkit.createLabel( body, "Manage the resources that this bundle exports." );
+        link = toolkit.createHyperlink(body, "Exports:", SWT.NONE);
+        link.setHref(ExportsForm.PAGE_ID);
+        link.addHyperlinkListener(this);
+        toolkit.createLabel(body, "Manage the resources that this bundle exports.");
     }
 
-
     @Override
-    public void linkActivated( HyperlinkEvent e )
+    public void linkActivated(HyperlinkEvent e)
     {
-        getPage().getEditor().setActivePage( ( String ) e.getHref() );
+        getPage().getEditor().setActivePage((String) e.getHref());
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentsForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentsForm.java
index cedc2cd..0271305 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentsForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentsForm.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
@@ -32,7 +31,6 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-
 public class ContentsForm extends SigilPage
 {
 
@@ -40,21 +38,19 @@
 
     private ISigilProjectModel project;
 
-
-    public ContentsForm( FormEditor editor, ISigilProjectModel project )
+    public ContentsForm(FormEditor editor, ISigilProjectModel project)
     {
-        super( editor, PAGE_ID, "Contents" );
+        super(editor, PAGE_ID, "Contents");
         this.project = project;
     }
 
-
     @Override
-    protected void createFormContent( IManagedForm managedForm )
+    protected void createFormContent(IManagedForm managedForm)
     {
         FormToolkit toolkit = managedForm.getToolkit();
 
         ScrolledForm form = managedForm.getForm();
-        form.setText( "Contents" );
+        form.setText("Contents");
 
         Composite body = form.getBody();
         TableWrapLayout layout = new TableWrapLayout();
@@ -64,34 +60,35 @@
         layout.rightMargin = 10;
         layout.numColumns = 1;
         layout.horizontalSpacing = 10;
-        body.setLayout( layout );
-        body.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+        body.setLayout(layout);
+        body.setLayoutData(new TableWrapData(TableWrapData.FILL));
 
-        Composite top = toolkit.createComposite( body );
+        Composite top = toolkit.createComposite(body);
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        top.setLayout( layout );
-        TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB );
+        top.setLayout(layout);
+        TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
         //data.colspan = 2;
-        top.setLayoutData( data );
+        top.setLayoutData(data);
 
-        Composite bottom = toolkit.createComposite( body );
+        Composite bottom = toolkit.createComposite(body);
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        bottom.setLayout( layout );
-        bottom.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+        bottom.setLayout(layout);
+        bottom.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
 
         try
         {
-            ClasspathSection classpath = new ClasspathSection( this, top, project );
-            managedForm.addPart( classpath );
+            ClasspathSection classpath = new ClasspathSection(this, top, project);
+            managedForm.addPart(classpath);
 
-            ResourceBuildSection runtimeBuild = new ResourceBuildSection( this, bottom, project );
-            managedForm.addPart( runtimeBuild );
+            ResourceBuildSection runtimeBuild = new ResourceBuildSection(this, bottom,
+                project);
+            managedForm.addPart(runtimeBuild);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to create contents form", e );
+            SigilCore.error("Failed to create contents form", e);
         }
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependenciesForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependenciesForm.java
index 179caa9..abb94ea 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependenciesForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependenciesForm.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.Set;
 
 import org.apache.felix.sigil.common.model.IModelElement;
@@ -35,7 +34,6 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-
 public class DependenciesForm extends SigilPage
 {
 
@@ -47,29 +45,26 @@
     private ImportPackagesSection importPackages;
     private RequiresBundleSection requiresSection;
 
-
-    public DependenciesForm( FormEditor editor, ISigilProjectModel project, Set<IModelElement> unresolved )
+    public DependenciesForm(FormEditor editor, ISigilProjectModel project, Set<IModelElement> unresolved)
     {
-        super( editor, PAGE_ID, "Dependencies" );
+        super(editor, PAGE_ID, "Dependencies");
         this.project = project;
         this.unresolvedElements = unresolved;
     }
 
-
     @Override
     public boolean canLeaveThePage()
     {
         return !isDirty();
     }
 
-
     @Override
-    protected void createFormContent( IManagedForm managedForm )
+    protected void createFormContent(IManagedForm managedForm)
     {
         FormToolkit toolkit = managedForm.getToolkit();
 
         ScrolledForm form = managedForm.getForm();
-        form.setText( "Dependencies" );
+        form.setText("Dependencies");
 
         Composite body = form.getBody();
         TableWrapLayout layout = new TableWrapLayout();
@@ -79,43 +74,46 @@
         layout.rightMargin = 10;
         layout.numColumns = 2;
         layout.horizontalSpacing = 10;
-        body.setLayout( layout );
-        body.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+        body.setLayout(layout);
+        body.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
 
-        Composite left = toolkit.createComposite( body );
+        Composite left = toolkit.createComposite(body);
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        left.setLayout( layout );
-        TableWrapData layoutData = new TableWrapData( TableWrapData.FILL_GRAB );
+        left.setLayout(layout);
+        TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB);
         layoutData.rowspan = 2;
-        left.setLayoutData( layoutData );
+        left.setLayoutData(layoutData);
 
-        Composite right = toolkit.createComposite( body );
+        Composite right = toolkit.createComposite(body);
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        right.setLayout( layout );
-        right.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+        right.setLayout(layout);
+        right.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
 
-        Composite bottom = toolkit.createComposite( body );
+        Composite bottom = toolkit.createComposite(body);
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        bottom.setLayout( layout );
-        bottom.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+        bottom.setLayout(layout);
+        bottom.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
 
         try
         {
-            importPackages = new ImportPackagesSection( this, left, project, unresolvedElements );
-            managedForm.addPart( importPackages );
+            importPackages = new ImportPackagesSection(this, left, project,
+                unresolvedElements);
+            managedForm.addPart(importPackages);
 
-            requiresSection = new RequiresBundleSection( this, right, project, unresolvedElements );
-            managedForm.addPart( requiresSection );
+            requiresSection = new RequiresBundleSection(this, right, project,
+                unresolvedElements);
+            managedForm.addPart(requiresSection);
 
-            DependencyManagementSection depMgmt = new DependencyManagementSection( this, bottom, project );
-            managedForm.addPart( depMgmt );
+            DependencyManagementSection depMgmt = new DependencyManagementSection(this,
+                bottom, project);
+            managedForm.addPart(depMgmt);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to create dependencies form", e );
+            SigilCore.error("Failed to create dependencies form", e);
         }
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependencyManagementSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependencyManagementSection.java
index 0f0a4b9..f8fd0ef 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependencyManagementSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependencyManagementSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -61,96 +60,94 @@
 import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.Section;
 
-
 public class DependencyManagementSection extends SigilSection
 {
 
     private Hyperlink hypConvertRBtoIP;
 
-
-    public DependencyManagementSection( SigilPage page, Composite parent, ISigilProjectModel project )
-        throws CoreException
+    public DependencyManagementSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
-    protected void createSection( Section section, FormToolkit toolkit ) throws CoreException
+    protected void createSection(Section section, FormToolkit toolkit)
+        throws CoreException
     {
-        setTitle( "Dependency Management" );
+        setTitle("Dependency Management");
 
-        Composite body = createGridBody( 1, false, toolkit );
+        Composite body = createGridBody(1, false, toolkit);
 
-        hypConvertRBtoIP = toolkit.createHyperlink( body, "Convert Required Bundles to Imported Packages", SWT.NONE );
-        hypConvertRBtoIP.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+        hypConvertRBtoIP = toolkit.createHyperlink(body,
+            "Convert Required Bundles to Imported Packages", SWT.NONE);
+        hypConvertRBtoIP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
 
-        hypConvertRBtoIP.addHyperlinkListener( new HyperlinkAdapter()
+        hypConvertRBtoIP.addHyperlinkListener(new HyperlinkAdapter()
         {
-            public void linkActivated( HyperlinkEvent e )
+            public void linkActivated(HyperlinkEvent e)
             {
                 run();
             }
-        } );
+        });
     }
 
-
     protected void run()
     {
         final Map<String, IPackageExport> exports = new HashMap<String, IPackageExport>();
         final Set<String> imports = new HashSet<String>();
 
         // Find all exports
-        final ExportedPackageFinder exportFinder = new ExportedPackageFinder( getProjectModel(),
-            new AccumulatorAdapter<IPackageExport>()
+        final ExportedPackageFinder exportFinder = new ExportedPackageFinder(
+            getProjectModel(), new AccumulatorAdapter<IPackageExport>()
             {
-                public void addElements( Collection<? extends IPackageExport> elements )
+                public void addElements(Collection<? extends IPackageExport> elements)
                 {
-                    for ( IPackageExport export : elements )
+                    for (IPackageExport export : elements)
                     {
-                        exports.put( export.getPackageName(), export );
+                        exports.put(export.getPackageName(), export);
                     }
                 }
-            } );
-        Job findExportsJob = new Job( "Find exports" )
+            });
+        Job findExportsJob = new Job("Find exports")
         {
-            protected IStatus run( IProgressMonitor monitor )
+            protected IStatus run(IProgressMonitor monitor)
             {
-                return exportFinder.run( monitor );
+                return exportFinder.run(monitor);
             }
         };
-        findExportsJob.setUser( true );
+        findExportsJob.setUser(true);
         findExportsJob.schedule();
 
         // Find imports from Java source
-        Job findImportsJob = new Job( "Find imports" )
+        Job findImportsJob = new Job("Find imports")
         {
-            protected IStatus run( IProgressMonitor monitor )
+            protected IStatus run(IProgressMonitor monitor)
             {
                 IJavaProject javaProject = getProjectModel().getJavaModel();
                 try
                 {
                     IPackageFragment[] packages = javaProject.getPackageFragments();
-                    for ( IPackageFragment pkg : packages )
+                    for (IPackageFragment pkg : packages)
                     {
                         ICompilationUnit[] compilationUnits = pkg.getCompilationUnits();
-                        for ( ICompilationUnit compilationUnit : compilationUnits )
+                        for (ICompilationUnit compilationUnit : compilationUnits)
                         {
                             IImportDeclaration[] importDecls = compilationUnit.getImports();
-                            for ( IImportDeclaration importDecl : importDecls )
+                            for (IImportDeclaration importDecl : importDecls)
                             {
-                                imports.add( getPackageName( importDecl ) );
+                                imports.add(getPackageName(importDecl));
                             }
                         }
                     }
                     return Status.OK_STATUS;
                 }
-                catch ( JavaModelException e )
+                catch (JavaModelException e)
                 {
-                    return new Status( IStatus.ERROR, SigilUI.PLUGIN_ID, 0, "Error finding imports", e );
+                    return new Status(IStatus.ERROR, SigilUI.PLUGIN_ID, 0,
+                        "Error finding imports", e);
                 }
             }
         };
-        findImportsJob.setUser( true );
+        findImportsJob.setUser(true);
         findImportsJob.schedule();
 
         // Wait for both jobs to complete
@@ -159,7 +156,7 @@
             findImportsJob.join();
             findExportsJob.join();
         }
-        catch ( InterruptedException e )
+        catch (InterruptedException e)
         {
             // Aborted, just do nothing
             return;
@@ -169,26 +166,26 @@
         IBundleModelElement bundleInfo = getProjectModel().getBundle().getBundleInfo();
         Collection<IPackageImport> existingImports = bundleInfo.getImports();
         Map<String, IPackageImport> existingImportsMap = new HashMap<String, IPackageImport>();
-        for ( IPackageImport existingImport : existingImports )
+        for (IPackageImport existingImport : existingImports)
         {
-            existingImportsMap.put( existingImport.getPackageName(), existingImport );
+            existingImportsMap.put(existingImport.getPackageName(), existingImport);
         }
 
         // Add imports to the bundle
         ModelElementFactory elementFactory = ModelElementFactory.getInstance();
         int count = 0;
-        for ( String pkgImport : imports )
+        for (String pkgImport : imports)
         {
-            IPackageExport export = exports.get( pkgImport );
-            if ( export != null && !existingImportsMap.containsKey( pkgImport ) )
+            IPackageExport export = exports.get(pkgImport);
+            if (export != null && !existingImportsMap.containsKey(pkgImport))
             {
                 VersionRange versionRange = ModelHelper.getDefaultRange(export.getVersion());
-                IPackageImport newImport = elementFactory.newModelElement( IPackageImport.class );
-                newImport.setPackageName( pkgImport );
-                newImport.setVersions( versionRange );
-                newImport.setOptional( false );
+                IPackageImport newImport = elementFactory.newModelElement(IPackageImport.class);
+                newImport.setPackageName(pkgImport);
+                newImport.setVersions(versionRange);
+                newImport.setOptional(false);
 
-                bundleInfo.addImport( newImport );
+                bundleInfo.addImport(newImport);
                 count++;
             }
         }
@@ -196,31 +193,31 @@
         // Remove required bundles
         Collection<IRequiredBundle> requiredBundles = bundleInfo.getRequiredBundles();
         int requiredBundlesSize = requiredBundles.size();
-        for ( IRequiredBundle requiredBundle : requiredBundles )
+        for (IRequiredBundle requiredBundle : requiredBundles)
         {
-            bundleInfo.removeRequiredBundle( requiredBundle );
+            bundleInfo.removeRequiredBundle(requiredBundle);
         }
 
         // Update the editor
-        if ( count + requiredBundlesSize > 0 )
+        if (count + requiredBundlesSize > 0)
         {
             IFormPart[] parts = getPage().getManagedForm().getParts();
-            for ( IFormPart formPart : parts )
+            for (IFormPart formPart : parts)
             {
                 formPart.refresh();
-                ( ( AbstractFormPart ) formPart ).markDirty();
+                ((AbstractFormPart) formPart).markDirty();
             }
         }
 
-        MessageDialog.openInformation( getManagedForm().getForm().getShell(), "Dependency Management", "Removed "
-            + requiredBundlesSize + " required bundle(s) and added " + count + " imported package(s)." );
+        MessageDialog.openInformation(getManagedForm().getForm().getShell(),
+            "Dependency Management", "Removed " + requiredBundlesSize
+                + " required bundle(s) and added " + count + " imported package(s).");
     }
 
-
-    private static String getPackageName( IImportDeclaration decl )
+    private static String getPackageName(IImportDeclaration decl)
     {
         String name = decl.getElementName();
-        int lastDot = name.lastIndexOf( '.' );
-        return name.substring( 0, lastDot );
+        int lastDot = name.lastIndexOf('.');
+        return name.substring(0, lastDot);
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExcludedResourcesFilter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExcludedResourcesFilter.java
index 782537d..4a94341 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExcludedResourcesFilter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExcludedResourcesFilter.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.HashSet;
 import java.util.Set;
 import java.util.regex.Pattern;
@@ -32,39 +31,35 @@
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 
-
 public class ExcludedResourcesFilter extends ViewerFilter
 {
 
     private final Set<Pattern> exclusionSet = new HashSet<Pattern>();
 
-
     public ExcludedResourcesFilter()
     {
         loadExclusions();
     }
 
-
     public final synchronized void loadExclusions()
     {
         exclusionSet.clear();
         IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
-        String[] exclusions = PrefsUtils.stringToArray( store.getString( SigilCore.DEFAULT_EXCLUDED_RESOURCES ) );
-        for ( String exclusion : exclusions )
+        String[] exclusions = PrefsUtils.stringToArray(store.getString(SigilCore.DEFAULT_EXCLUDED_RESOURCES));
+        for (String exclusion : exclusions)
         {
-            exclusionSet.add( GlobCompiler.compile( exclusion ) );
+            exclusionSet.add(GlobCompiler.compile(exclusion));
         }
     }
 
-
     @Override
-    public synchronized boolean select( Viewer viewer, Object parentElement, Object element )
+    public synchronized boolean select(Viewer viewer, Object parentElement, Object element)
     {
-        IResource file = ( IResource ) element;
+        IResource file = (IResource) element;
         String path = file.getName();
-        for ( Pattern p : exclusionSet )
+        for (Pattern p : exclusionSet)
         {
-            if ( p.matcher( path ).matches() )
+            if (p.matcher(path).matches())
             {
                 return false;
             }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportPackagesSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportPackagesSection.java
index 7f2c013..05242bd 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportPackagesSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportPackagesSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.Iterator;
 import java.util.List;
 
@@ -48,50 +47,47 @@
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.osgi.framework.Version;
 
-
 public class ExportPackagesSection extends BundleDependencySection
 {
 
-    public ExportPackagesSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public ExportPackagesSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
     @Override
     protected String getTitle()
     {
         return "Export Packages";
     }
 
-
     @Override
-    protected Label createLabel( Composite parent, FormToolkit toolkit )
+    protected Label createLabel(Composite parent, FormToolkit toolkit)
     {
-        return toolkit.createLabel( parent, "Specify which packages this bundle shares with other bundles." );
+        return toolkit.createLabel(parent,
+            "Specify which packages this bundle shares with other bundles.");
     }
 
-
     @Override
     protected IContentProvider getContentProvider()
     {
         return new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
                 return getBundle().getBundleInfo().getExports().toArray();
             }
         };
     }
 
-
     @Override
     protected void handleAdd()
     {
-        NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog( getSection().getShell(),
-            "Add Exported Package", null, getProjectModel(), true );
+        NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog(
+            getSection().getShell(), "Add Exported Package", null, getProjectModel(),
+            true);
 
-        if ( dialog.open() == Window.OK )
+        if (dialog.open() == Window.OK)
         {
             try
             {
@@ -99,12 +95,13 @@
                 boolean exportsAdded = false;
 
                 List<IPackageFragment> newPkgFragments = dialog.getSelectedElements();
-                for ( IPackageFragment pkgFragment : newPkgFragments )
+                for (IPackageFragment pkgFragment : newPkgFragments)
                 {
-                    IPackageExport pkgExport = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
-                    pkgExport.setPackageName( pkgFragment.getElementName() );
-                    pkgExport.setVersion( dialog.getVersion() );
-                    getBundle().getBundleInfo().addExport( pkgExport );
+                    IPackageExport pkgExport = ModelElementFactory.getInstance().newModelElement(
+                        IPackageExport.class);
+                    pkgExport.setPackageName(pkgFragment.getElementName());
+                    pkgExport.setVersion(dialog.getVersion());
+                    getBundle().getBundleInfo().addExport(pkgExport);
 
                     exportsAdded = true;
                 }
@@ -114,106 +111,107 @@
 
                 boolean shouldAddImports = OptionalPrompt.optionallyPrompt(
                     SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT, "Add Exports",
-                    "Should corresponding imports be added?", getSection().getShell() );
-                if ( shouldAddImports )
+                    "Should corresponding imports be added?", getSection().getShell());
+                if (shouldAddImports)
                 {
-                    for ( IPackageFragment pkgFragment : newPkgFragments )
+                    for (IPackageFragment pkgFragment : newPkgFragments)
                     {
                         IPackageImport pkgImport = ModelElementFactory.getInstance().newModelElement(
-                            IPackageImport.class );
-                        pkgImport.setPackageName( pkgFragment.getElementName() );
+                            IPackageImport.class);
+                        pkgImport.setPackageName(pkgFragment.getElementName());
                         Version version = dialog.getVersion();
-                        if ( version == null )
+                        if (version == null)
                         {
                             version = getBundle().getVersion();
                         }
                         VersionRange versionRange = ModelHelper.getDefaultRange(version);
-                        pkgImport.setVersions( versionRange );
+                        pkgImport.setVersions(versionRange);
 
-                        getBundle().getBundleInfo().addImport( pkgImport );
+                        getBundle().getBundleInfo().addImport(pkgImport);
 
                         importsAdded = true;
                     }
                 }
 
-                if ( importsAdded )
+                if (importsAdded)
                 {
                     refreshAllPages();
                     markDirty();
                 }
-                else if ( exportsAdded )
+                else if (exportsAdded)
                 {
                     refresh();
                     markDirty();
                 }
             }
-            catch ( ModelElementFactoryException e )
+            catch (ModelElementFactoryException e)
             {
-                SigilCore.error( "Failed to buiild model element for package export", e );
+                SigilCore.error("Failed to buiild model element for package export", e);
             }
         }
     }
 
-
     @SuppressWarnings("unchecked")
     @Override
     protected void handleEdit()
     {
-        IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+        IStructuredSelection selection = (IStructuredSelection) getSelection();
 
         boolean changed = false;
 
-        if ( !selection.isEmpty() )
+        if (!selection.isEmpty())
         {
-            for ( Iterator<IPackageExport> i = selection.iterator(); i.hasNext(); )
+            for (Iterator<IPackageExport> i = selection.iterator(); i.hasNext();)
             {
                 IPackageExport packageExport = i.next();
-                NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog( getSection().getShell(),
-                    "Edit Imported Package", packageExport, getProjectModel(), false );
-                if ( dialog.open() == Window.OK )
+                NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog(
+                    getSection().getShell(), "Edit Imported Package", packageExport,
+                    getProjectModel(), false);
+                if (dialog.open() == Window.OK)
                 {
                     changed = true;
                     IPackageFragment pkgFragment = dialog.getSelectedElement();
-                    packageExport.setPackageName( pkgFragment.getElementName() );
-                    packageExport.setVersion( dialog.getVersion() );
+                    packageExport.setPackageName(pkgFragment.getElementName());
+                    packageExport.setVersion(dialog.getVersion());
                 }
             }
         }
 
-        if ( changed )
+        if (changed)
         {
             refresh();
             markDirty();
         }
     }
 
-
     @SuppressWarnings("unchecked")
     @Override
     protected void handleRemoved()
     {
-        IStructuredSelection selection = ( IStructuredSelection ) getSelection();
-        
-        if ( !selection.isEmpty() )
+        IStructuredSelection selection = (IStructuredSelection) getSelection();
+
+        if (!selection.isEmpty())
         {
             boolean importsRemoved = false;
 
-            boolean shouldRemoveImports = OptionalPrompt.optionallyPrompt( 
+            boolean shouldRemoveImports = OptionalPrompt.optionallyPrompt(
                 SigilCore.PREFERENCES_REMOVE_IMPORT_FOR_EXPORT, "Remove Exports",
-                "Should corresponding imports be removed?", getSection().getShell() );
-            
+                "Should corresponding imports be removed?", getSection().getShell());
+
             IBundleModelElement info = getBundle().getBundleInfo();
-            
-            for ( Iterator<IPackageExport> i = selection.iterator(); i.hasNext(); )
+
+            for (Iterator<IPackageExport> i = selection.iterator(); i.hasNext();)
             {
                 IPackageExport pe = i.next();
-                info.removeExport( pe );
-                
+                info.removeExport(pe);
+
                 // Remove corresponding imports (maybe)
-                if (shouldRemoveImports) 
-                {                    
-                    for(IPackageImport pi : info.getImports() ) {
-                        if (pi.getPackageName().equals(pe.getPackageName())) {
+                if (shouldRemoveImports)
+                {
+                    for (IPackageImport pi : info.getImports())
+                    {
+                        if (pi.getPackageName().equals(pe.getPackageName()))
+                        {
                             importsRemoved = true;
                             info.removeImport(pi);
                         }
@@ -221,28 +219,27 @@
                 }
             }
 
-            if ( importsRemoved )
+            if (importsRemoved)
             {
                 refreshAllPages();
             }
-            else {
+            else
+            {
                 refresh();
             }
-            
+
             markDirty();
         }
     }
 
-
     /**
      * 
      */
     private void refreshAllPages()
     {
-        ( ( SigilProjectEditorPart ) getPage().getEditor() ).refreshAllPages();
+        ((SigilProjectEditorPart) getPage().getEditor()).refreshAllPages();
     }
 
-
     private ISigilBundle getBundle()
     {
         return getProjectModel().getBundle();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportsForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportsForm.java
index c83515b..9537ff6 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportsForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportsForm.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
@@ -31,7 +30,6 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-
 public class ExportsForm extends SigilPage
 {
 
@@ -39,19 +37,17 @@
 
     private ISigilProjectModel project;
 
-
-    public ExportsForm( FormEditor editor, ISigilProjectModel project )
+    public ExportsForm(FormEditor editor, ISigilProjectModel project)
     {
-        super( editor, PAGE_ID, "Exports" );
+        super(editor, PAGE_ID, "Exports");
         this.project = project;
     }
 
-
     @Override
-    protected void createFormContent( IManagedForm managedForm )
+    protected void createFormContent(IManagedForm managedForm)
     {
         ScrolledForm form = managedForm.getForm();
-        form.setText( "Exports" );
+        form.setText("Exports");
 
         Composite body = form.getBody();
         TableWrapLayout layout = new TableWrapLayout();
@@ -62,17 +58,18 @@
         layout.numColumns = 1;
         layout.horizontalSpacing = 10;
         layout.verticalSpacing = 20;
-        body.setLayout( layout );
-        body.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+        body.setLayout(layout);
+        body.setLayoutData(new TableWrapData(TableWrapData.FILL));
 
         try
         {
-            ExportPackagesSection exportPackages = new ExportPackagesSection( this, body, project );
-            managedForm.addPart( exportPackages );
+            ExportPackagesSection exportPackages = new ExportPackagesSection(this, body,
+                project);
+            managedForm.addPart(exportPackages);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to create contents form", e );
+            SigilCore.error("Failed to create contents form", e);
         }
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/GeneralInfoSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/GeneralInfoSection.java
index 77c713c..850a9e4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/GeneralInfoSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/GeneralInfoSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.common.model.ModelElementFactory;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.common.model.osgi.IBundleModelElement;
@@ -45,7 +44,6 @@
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.Version;
 
-
 /**
  * @author dave
  *
@@ -69,200 +67,194 @@
     private SigilFormEntry activatorEntry;
     private SigilFormEntry fragmentHostEntry;
 
-
     /**
      * @param parent
      * @param toolkit
      * @param style
      * @throws CoreException 
      */
-    public GeneralInfoSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public GeneralInfoSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
-    protected void createSection( Section section, FormToolkit toolkit )
+    protected void createSection(Section section, FormToolkit toolkit)
     {
-        setTitle( "General Information" );
+        setTitle("General Information");
 
-        Composite body = createGridBody( 3, false, toolkit );
+        Composite body = createGridBody(3, false, toolkit);
 
-        Label label = toolkit.createLabel( body, "This section describes general information about this project." );
-        label.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, true, false, 3, 1 ) );
+        Label label = toolkit.createLabel(body,
+            "This section describes general information about this project.");
+        label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
 
-        symbolicNameEntry = new SigilFormEntry( body, toolkit, "Symbolic Name" );
-        symbolicNameEntry.setFormEntryListener( new SigilFormEntryAdapter()
+        symbolicNameEntry = new SigilFormEntry(body, toolkit, "Symbolic Name");
+        symbolicNameEntry.setFormEntryListener(new SigilFormEntryAdapter()
         {
             @Override
-            public void textValueChanged( SigilFormEntry form )
+            public void textValueChanged(SigilFormEntry form)
             {
-                symbolicName = nullIfEmpty( ( String ) form.getValue() );
+                symbolicName = nullIfEmpty((String) form.getValue());
                 checkDirty();
             }
-        } );
+        });
 
-        nameEntry = new SigilFormEntry( body, toolkit, "Name" );
-        nameEntry.setFormEntryListener( new SigilFormEntryAdapter()
+        nameEntry = new SigilFormEntry(body, toolkit, "Name");
+        nameEntry.setFormEntryListener(new SigilFormEntryAdapter()
         {
             @Override
-            public void textValueChanged( SigilFormEntry form )
+            public void textValueChanged(SigilFormEntry form)
             {
-                name = nullIfEmpty( ( String ) form.getValue() );
+                name = nullIfEmpty((String) form.getValue());
                 checkDirty();
             }
-        } );
+        });
 
-        descriptionEntry = new SigilFormEntry( body, toolkit, "Description" );
-        descriptionEntry.setFormEntryListener( new SigilFormEntryAdapter()
+        descriptionEntry = new SigilFormEntry(body, toolkit, "Description");
+        descriptionEntry.setFormEntryListener(new SigilFormEntryAdapter()
         {
             @Override
-            public void textValueChanged( SigilFormEntry form )
+            public void textValueChanged(SigilFormEntry form)
             {
-                description = nullIfEmpty( ( String ) form.getValue() );
+                description = nullIfEmpty((String) form.getValue());
                 checkDirty();
             }
-        } );
+        });
 
         IFormValueConverter converter = new IFormValueConverter()
         {
-            public String getLabel( Object value )
+            public String getLabel(Object value)
             {
-                Version v = ( Version ) value;
+                Version v = (Version) value;
                 return v.toString();
             }
 
-
-            public Object getValue( String label )
+            public Object getValue(String label)
             {
-                return VersionTable.getVersion( label );
+                return VersionTable.getVersion(label);
             }
         };
 
-        versionEntry = new SigilFormEntry( body, toolkit, "Version", null, converter );
-        versionEntry.setFormEntryListener( new SigilFormEntryAdapter()
+        versionEntry = new SigilFormEntry(body, toolkit, "Version", null, converter);
+        versionEntry.setFormEntryListener(new SigilFormEntryAdapter()
         {
             @Override
-            public void textValueChanged( SigilFormEntry form )
+            public void textValueChanged(SigilFormEntry form)
             {
-                version = ( Version ) form.getValue();
+                version = (Version) form.getValue();
                 checkDirty();
             }
-        } );
+        });
 
-        providerEntry = new SigilFormEntry( body, toolkit, "Provider" );
-        providerEntry.setFormEntryListener( new SigilFormEntryAdapter()
+        providerEntry = new SigilFormEntry(body, toolkit, "Provider");
+        providerEntry.setFormEntryListener(new SigilFormEntryAdapter()
         {
             @Override
-            public void textValueChanged( SigilFormEntry form )
+            public void textValueChanged(SigilFormEntry form)
             {
-                provider = nullIfEmpty( ( String ) form.getValue() );
+                provider = nullIfEmpty((String) form.getValue());
                 checkDirty();
             }
-        } );
+        });
 
-        activatorEntry = new SigilFormEntry( body, toolkit, "Bundle Activator", "Browse...", null );
-        activatorEntry.setFormEntryListener( new SigilFormEntryAdapter()
+        activatorEntry = new SigilFormEntry(body, toolkit, "Bundle Activator",
+            "Browse...", null);
+        activatorEntry.setFormEntryListener(new SigilFormEntryAdapter()
         {
             @Override
-            public void textValueChanged( SigilFormEntry form )
+            public void textValueChanged(SigilFormEntry form)
             {
-                activator = ( String ) form.getValue();
+                activator = (String) form.getValue();
                 checkDirty();
             }
 
-
             @Override
-            public void browseButtonSelected( SigilFormEntry form )
+            public void browseButtonSelected(SigilFormEntry form)
             {
                 BackgroundLoadingSelectionDialog<String> dialog = ResourcesDialogHelper.createClassSelectDialog(
-                    getShell(), "Add Bundle Activator", getProjectModel(), activator, BundleActivator.class.getName() );
+                    getShell(), "Add Bundle Activator", getProjectModel(), activator,
+                    BundleActivator.class.getName());
 
-                if ( dialog.open() == Window.OK )
+                if (dialog.open() == Window.OK)
                 {
-                    form.setValue( dialog.getSelectedElement() );
+                    form.setValue(dialog.getSelectedElement());
                 }
             }
-        } );
+        });
 
         converter = new IFormValueConverter()
         {
-            public String getLabel( Object value )
+            public String getLabel(Object value)
             {
-                IRequiredBundle b = ( IRequiredBundle ) value;
+                IRequiredBundle b = (IRequiredBundle) value;
                 return b == null ? null : b.getSymbolicName() + " " + b.getVersions();
             }
 
-
-            public Object getValue( String label )
+            public Object getValue(String label)
             {
                 return null;
             }
         };
 
-        fragmentHostEntry = new SigilFormEntry( body, toolkit, "Fragment Host", "Browse...", converter );
-        fragmentHostEntry.setFormEntryListener( new SigilFormEntryAdapter()
+        fragmentHostEntry = new SigilFormEntry(body, toolkit, "Fragment Host",
+            "Browse...", converter);
+        fragmentHostEntry.setFormEntryListener(new SigilFormEntryAdapter()
         {
             @Override
-            public void textValueChanged( SigilFormEntry form )
+            public void textValueChanged(SigilFormEntry form)
             {
-                fragmentHost = ( IRequiredBundle ) form.getValue();
+                fragmentHost = (IRequiredBundle) form.getValue();
                 checkDirty();
             }
 
-
             @Override
-            public void browseButtonSelected( SigilFormEntry form )
+            public void browseButtonSelected(SigilFormEntry form)
             {
-                NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper
-                    .createRequiredBundleDialog( getSection().getShell(), "Add Required Bundle", getProjectModel(),
-                        null, getBundle().getBundleInfo().getRequiredBundles() );
+                NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog(
+                    getSection().getShell(), "Add Required Bundle", getProjectModel(),
+                    null, getBundle().getBundleInfo().getRequiredBundles());
 
-                if ( dialog.open() == Window.OK )
+                if (dialog.open() == Window.OK)
                 {
-                    IRequiredBundle required = ModelElementFactory.getInstance()
-                        .newModelElement( IRequiredBundle.class );
-                    required.setSymbolicName( dialog.getSelectedName() );
-                    required.setVersions( dialog.getSelectedVersions() );
-                    form.setValue( required );
+                    IRequiredBundle required = ModelElementFactory.getInstance().newModelElement(
+                        IRequiredBundle.class);
+                    required.setSymbolicName(dialog.getSelectedName());
+                    required.setVersions(dialog.getSelectedVersions());
+                    form.setValue(required);
                 }
             }
-        } );
-        fragmentHostEntry.setFreeText( false );
+        });
+        fragmentHostEntry.setFreeText(false);
     }
 
-
-    private static String nullIfEmpty( String value )
+    private static String nullIfEmpty(String value)
     {
-        if ( value.trim().length() == 0 )
+        if (value.trim().length() == 0)
         {
             return null;
         }
         return value;
     }
 
-
     private Shell getShell()
     {
         return getSection().getShell();
     }
 
-
     @Override
-    public void commit( boolean onSave )
+    public void commit(boolean onSave)
     {
-        getBundle().getBundleInfo().setSymbolicName( symbolicName );
-        getBundle().getBundleInfo().setName( name );
-        getBundle().getBundleInfo().setVersion( version );
-        getBundle().getBundleInfo().setDescription( description );
-        getBundle().getBundleInfo().setVendor( provider );
-        getBundle().getBundleInfo().setFragmentHost( fragmentHost );
-        getBundle().getBundleInfo().setActivator( activator );
+        getBundle().getBundleInfo().setSymbolicName(symbolicName);
+        getBundle().getBundleInfo().setName(name);
+        getBundle().getBundleInfo().setVersion(version);
+        getBundle().getBundleInfo().setDescription(description);
+        getBundle().getBundleInfo().setVendor(provider);
+        getBundle().getBundleInfo().setFragmentHost(fragmentHost);
+        getBundle().getBundleInfo().setActivator(activator);
 
-        super.commit( onSave );
+        super.commit(onSave);
     }
 
-
     @Override
     public void refresh()
     {
@@ -274,39 +266,42 @@
         fragmentHost = getProjectModel().getBundle().getBundleInfo().getFragmentHost();
         activator = getProjectModel().getBundle().getBundleInfo().getActivator();
 
-        nameEntry.setValue( name );
-        symbolicNameEntry.setValue( symbolicName );
-        versionEntry.setValue( version );
-        descriptionEntry.setValue( description );
-        providerEntry.setValue( provider );
-        fragmentHostEntry.setValue( fragmentHost );
-        activatorEntry.setValue( activator );
+        nameEntry.setValue(name);
+        symbolicNameEntry.setValue(symbolicName);
+        versionEntry.setValue(version);
+        descriptionEntry.setValue(description);
+        providerEntry.setValue(provider);
+        fragmentHostEntry.setValue(fragmentHost);
+        activatorEntry.setValue(activator);
 
         super.refresh();
     }
 
-
     private void checkDirty()
     {
-        boolean dirty = different( symbolicName, getProjectModel().getBundle().getBundleInfo().getSymbolicName() )
-            || different( name, getProjectModel().getBundle().getBundleInfo().getName() )
-            || different( version, getProjectModel().getBundle().getBundleInfo().getVersion() )
-            || different( description, getProjectModel().getBundle().getBundleInfo().getDescription() )
-            || different( provider, getProjectModel().getBundle().getBundleInfo().getVendor() )
-            || different( fragmentHost, getProjectModel().getBundle().getBundleInfo().getFragmentHost() )
-            || different( activator, getProjectModel().getBundle().getBundleInfo().getActivator() );
+        boolean dirty = different(symbolicName,
+            getProjectModel().getBundle().getBundleInfo().getSymbolicName())
+            || different(name, getProjectModel().getBundle().getBundleInfo().getName())
+            || different(version,
+                getProjectModel().getBundle().getBundleInfo().getVersion())
+            || different(description,
+                getProjectModel().getBundle().getBundleInfo().getDescription())
+            || different(provider,
+                getProjectModel().getBundle().getBundleInfo().getVendor())
+            || different(fragmentHost,
+                getProjectModel().getBundle().getBundleInfo().getFragmentHost())
+            || different(activator,
+                getProjectModel().getBundle().getBundleInfo().getActivator());
 
-        if ( dirty )
+        if (dirty)
             markDirty();
     }
 
-
-    private boolean different( Object val1, Object val2 )
+    private boolean different(Object val1, Object val2)
     {
-        return val1 == null ? val2 != null : !val1.equals( val2 );
+        return val1 == null ? val2 != null : !val1.equals(val2);
     }
 
-
     private ISigilBundle getBundle()
     {
         return getProjectModel().getBundle();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/IDependencyChecker.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/IDependencyChecker.java
index 695f8d0..e78c0df 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/IDependencyChecker.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/IDependencyChecker.java
@@ -19,15 +19,12 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
 
-
 public interface IDependencyChecker
 {
-    boolean isSatisfied( IPackageImport packageImport );
+    boolean isSatisfied(IPackageImport packageImport);
 
-
-    boolean isSatisfied( IRequiredBundle requiredBundle );
+    boolean isSatisfied(IRequiredBundle requiredBundle);
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ImportPackagesSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ImportPackagesSection.java
index b5eecc3..993a406 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ImportPackagesSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ImportPackagesSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -43,91 +42,85 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
-
 public class ImportPackagesSection extends BundleDependencySection
 {
 
-    public ImportPackagesSection( SigilPage page, Composite parent, ISigilProjectModel project,
-        Set<IModelElement> unresolvedPackages ) throws CoreException
+    public ImportPackagesSection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedPackages) throws CoreException
     {
-        super( page, parent, project, unresolvedPackages );
+        super(page, parent, project, unresolvedPackages);
     }
 
-
     @Override
     protected String getTitle()
     {
         return "Import Packages";
     }
 
-
     @Override
-    protected Label createLabel( Composite parent, FormToolkit toolkit )
+    protected Label createLabel(Composite parent, FormToolkit toolkit)
     {
-        return toolkit.createLabel( parent, "Specify which packages this bundle imports from other bundles." );
+        return toolkit.createLabel(parent,
+            "Specify which packages this bundle imports from other bundles.");
     }
 
-
     @Override
     protected IContentProvider getContentProvider()
     {
         return new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                ArrayList<IPackageImport> imports = new ArrayList<IPackageImport>( getBundle().getBundleInfo()
-                    .getImports() );
-                Collections.sort( imports, new Comparator<IPackageImport>()
+                ArrayList<IPackageImport> imports = new ArrayList<IPackageImport>(
+                    getBundle().getBundleInfo().getImports());
+                Collections.sort(imports, new Comparator<IPackageImport>()
                 {
-                    public int compare( IPackageImport o1, IPackageImport o2 )
+                    public int compare(IPackageImport o1, IPackageImport o2)
                     {
-                        return o1.getPackageName().compareTo( o2.getPackageName() );
+                        return o1.getPackageName().compareTo(o2.getPackageName());
                     }
-                } );
+                });
                 return imports.toArray();
             }
         };
     }
 
-
     protected ISigilBundle getBundle()
     {
         return getProjectModel().getBundle();
     }
 
-
     @Override
     protected void handleAdd()
     {
         NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog(
-            getSection().getShell(), "Add Imported Package", getProjectModel(), null, getBundle().getBundleInfo()
-                .getImports() );
+            getSection().getShell(), "Add Imported Package", getProjectModel(), null,
+            getBundle().getBundleInfo().getImports());
 
-        if ( dialog.open() == Window.OK )
+        if (dialog.open() == Window.OK)
         {
-            IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
-            pi.setPackageName( dialog.getSelectedName() );
-            pi.setVersions( dialog.getSelectedVersions() );
-            pi.setOptional( dialog.isOptional() );
+            IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+                IPackageImport.class);
+            pi.setPackageName(dialog.getSelectedName());
+            pi.setVersions(dialog.getSelectedVersions());
+            pi.setOptional(dialog.isOptional());
 
-            getBundle().getBundleInfo().addImport( pi );
+            getBundle().getBundleInfo().addImport(pi);
             refresh();
             markDirty();
         }
     }
 
-
     @SuppressWarnings("unchecked")
     @Override
     protected void handleRemoved()
     {
-        IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+        IStructuredSelection selection = (IStructuredSelection) getSelection();
 
-        if ( !selection.isEmpty() )
+        if (!selection.isEmpty())
         {
-            for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); )
+            for (Iterator<IPackageImport> i = selection.iterator(); i.hasNext();)
             {
-                getBundle().getBundleInfo().removeImport( i.next() );
+                getBundle().getBundleInfo().removeImport(i.next());
             }
 
             refresh();
@@ -135,38 +128,38 @@
         }
     }
 
-
     @SuppressWarnings("unchecked")
     @Override
     protected void handleEdit()
     {
-        IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+        IStructuredSelection selection = (IStructuredSelection) getSelection();
 
         boolean changed = false;
 
-        if ( !selection.isEmpty() )
+        if (!selection.isEmpty())
         {
-            for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); )
+            for (Iterator<IPackageImport> i = selection.iterator(); i.hasNext();)
             {
                 IPackageImport packageImport = i.next();
-                NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper
-                    .createImportDialog( getSection().getShell(), "Edit Imported Package", getProjectModel(),
-                        packageImport, getBundle().getBundleInfo().getImports() );
-                if ( dialog.open() == Window.OK )
+                NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog(
+                    getSection().getShell(), "Edit Imported Package", getProjectModel(),
+                    packageImport, getBundle().getBundleInfo().getImports());
+                if (dialog.open() == Window.OK)
                 {
                     changed = true;
-                    IPackageImport newImport = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
-                    newImport.setPackageName( dialog.getSelectedName() );
-                    newImport.setVersions( dialog.getSelectedVersions() );
-                    newImport.setOptional( dialog.isOptional() );
+                    IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(
+                        IPackageImport.class);
+                    newImport.setPackageName(dialog.getSelectedName());
+                    newImport.setVersions(dialog.getSelectedVersions());
+                    newImport.setOptional(dialog.isOptional());
 
-                    getBundle().getBundleInfo().removeImport( packageImport );
-                    getBundle().getBundleInfo().addImport( newImport );
+                    getBundle().getBundleInfo().removeImport(packageImport);
+                    getBundle().getBundleInfo().addImport(newImport);
                 }
             }
         }
 
-        if ( changed )
+        if (changed)
         {
             refresh();
             markDirty();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewPackageExportDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewPackageExportDialog.java
index 5b294c0..b6aeb1d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewPackageExportDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewPackageExportDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.Comparator;
 
 import org.apache.felix.sigil.common.osgi.VersionTable;
@@ -40,19 +39,17 @@
 import org.eclipse.swt.widgets.Text;
 import org.osgi.framework.Version;
 
-
 public class NewPackageExportDialog extends BackgroundLoadingSelectionDialog<IPackageFragment>
 {
 
     private static final IElementDescriptor<IPackageFragment> PKG_FRAGMENT_STRINGIFIER = new IElementDescriptor<IPackageFragment>()
     {
-        public String getLabel( IPackageFragment element )
+        public String getLabel(IPackageFragment element)
         {
-            return getName( element );
+            return getName(element);
         }
 
-
-        public String getName( IPackageFragment element )
+        public String getName(IPackageFragment element)
         {
             return element.getElementName();
         }
@@ -60,122 +57,116 @@
 
     private static final Comparator<IPackageFragment> PKG_FRAGMENT_COMPARATOR = new Comparator<IPackageFragment>()
     {
-        public int compare( IPackageFragment o1, IPackageFragment o2 )
+        public int compare(IPackageFragment o1, IPackageFragment o2)
         {
-            return o1.getElementName().compareTo( o2.getElementName() );
+            return o1.getElementName().compareTo(o2.getElementName());
         }
     };
 
     private Version version = null;
     private String error = null;
-    private Version projectVersion = VersionTable.getVersion( 0, 0, 0 );
+    private Version projectVersion = VersionTable.getVersion(0, 0, 0);
 
     private Button btnInheritBundleVersion;
     private Button btnExplicitVersion;
     private Text txtVersion;
 
-
-    public NewPackageExportDialog( Shell parentShell, boolean multiSelect )
+    public NewPackageExportDialog(Shell parentShell, boolean multiSelect)
     {
-        super( parentShell, "Package:", multiSelect );
-        setDescriptor( PKG_FRAGMENT_STRINGIFIER );
-        setComparator( PKG_FRAGMENT_COMPARATOR );
+        super(parentShell, "Package:", multiSelect);
+        setDescriptor(PKG_FRAGMENT_STRINGIFIER);
+        setComparator(PKG_FRAGMENT_COMPARATOR);
     }
 
-
     @Override
-    protected Control createDialogArea( Composite parent )
+    protected Control createDialogArea(Composite parent)
     {
         // Create controls
-        Composite container = ( Composite ) super.createDialogArea( parent );
-        Composite composite = new Composite( container, SWT.NONE );
+        Composite container = (Composite) super.createDialogArea(parent);
+        Composite composite = new Composite(container, SWT.NONE);
 
-        Group grpVersion = new Group( composite, SWT.NONE );
-        grpVersion.setText( "Version" );
+        Group grpVersion = new Group(composite, SWT.NONE);
+        grpVersion.setText("Version");
 
-        btnInheritBundleVersion = new Button( grpVersion, SWT.RADIO );
-        btnInheritBundleVersion.setText( "Inherit bundle version" );
-        new Label( grpVersion, SWT.NONE ); // Spacer
-        btnExplicitVersion = new Button( grpVersion, SWT.RADIO );
-        btnExplicitVersion.setText( "Fixed version:" );
-        txtVersion = new Text( grpVersion, SWT.BORDER );
+        btnInheritBundleVersion = new Button(grpVersion, SWT.RADIO);
+        btnInheritBundleVersion.setText("Inherit bundle version");
+        new Label(grpVersion, SWT.NONE); // Spacer
+        btnExplicitVersion = new Button(grpVersion, SWT.RADIO);
+        btnExplicitVersion.setText("Fixed version:");
+        txtVersion = new Text(grpVersion, SWT.BORDER);
 
         // Initialize
-        if ( version == null )
+        if (version == null)
         {
-            btnInheritBundleVersion.setSelection( true );
-            txtVersion.setEnabled( false );
-            txtVersion.setText( projectVersion.toString() );
+            btnInheritBundleVersion.setSelection(true);
+            txtVersion.setEnabled(false);
+            txtVersion.setText(projectVersion.toString());
         }
         else
         {
-            btnExplicitVersion.setSelection( true );
-            txtVersion.setEnabled( true );
-            txtVersion.setText( version.toString() );
+            btnExplicitVersion.setSelection(true);
+            txtVersion.setEnabled(true);
+            txtVersion.setText(version.toString());
         }
         updateButtons();
 
         // Listeners
         Listener radioAndTextListener = new Listener()
         {
-            public void handleEvent( Event event )
+            public void handleEvent(Event event)
             {
                 error = null;
-                if ( btnInheritBundleVersion.getSelection() )
+                if (btnInheritBundleVersion.getSelection())
                 {
                     version = null;
-                    txtVersion.setEnabled( false );
+                    txtVersion.setEnabled(false);
                 }
                 else
                 {
-                    txtVersion.setEnabled( true );
+                    txtVersion.setEnabled(true);
                     try
                     {
-                        version = VersionTable.getVersion( txtVersion.getText() );
+                        version = VersionTable.getVersion(txtVersion.getText());
                     }
-                    catch ( IllegalArgumentException e )
+                    catch (IllegalArgumentException e)
                     {
                         error = "Invalid version";
                     }
                 }
-                setErrorMessage( error );
+                setErrorMessage(error);
                 updateButtons();
             }
         };
-        txtVersion.addListener( SWT.Modify, radioAndTextListener );
-        btnInheritBundleVersion.addListener( SWT.Selection, radioAndTextListener );
-        btnExplicitVersion.addListener( SWT.Selection, radioAndTextListener );
+        txtVersion.addListener(SWT.Modify, radioAndTextListener);
+        btnInheritBundleVersion.addListener(SWT.Selection, radioAndTextListener);
+        btnExplicitVersion.addListener(SWT.Selection, radioAndTextListener);
 
         // Layout
-        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        composite.setLayout( new GridLayout( 1, false ) );
-        grpVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        grpVersion.setLayout( new GridLayout( 2, false ) );
-        txtVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        composite.setLayout(new GridLayout(1, false));
+        grpVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        grpVersion.setLayout(new GridLayout(2, false));
+        txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
 
         return container;
     }
 
-
     @Override
     protected boolean canComplete()
     {
         return super.canComplete() && error == null;
     }
 
-
-    public void setProjectVersion( Version projectVersion )
+    public void setProjectVersion(Version projectVersion)
     {
         this.projectVersion = projectVersion;
     }
 
-
-    public void setVersion( Version version )
+    public void setVersion(Version version)
     {
         this.version = version;
     }
 
-
     public Version getVersion()
     {
         return version;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewResourceSelectionDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewResourceSelectionDialog.java
index 5aa0b54..ab14e0e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewResourceSelectionDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewResourceSelectionDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.common.model.osgi.IVersionedModelElement;
 import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.eclipse.model.util.ModelHelper;
@@ -39,7 +38,6 @@
 import org.eclipse.swt.widgets.Shell;
 import org.osgi.framework.Version;
 
-
 public class NewResourceSelectionDialog<E extends IVersionedModelElement> extends BackgroundLoadingSelectionDialog<E>
 {
 
@@ -50,138 +48,129 @@
     private VersionRange selectedVersions = null;
     private boolean optional = false;
 
-
-    public NewResourceSelectionDialog( Shell parentShell, String selectionLabel, boolean multi )
+    public NewResourceSelectionDialog(Shell parentShell, String selectionLabel, boolean multi)
     {
-        super( parentShell, selectionLabel, multi );
+        super(parentShell, selectionLabel, multi);
     }
 
-
-    public void setOptionalEnabled( boolean enabled )
+    public void setOptionalEnabled(boolean enabled)
     {
         optionalEnabled = enabled;
     }
 
-
     @Override
-    protected Control createDialogArea( Composite parent )
+    protected Control createDialogArea(Composite parent)
     {
         // Create controls
-        Composite container = ( Composite ) super.createDialogArea( parent );
-        Composite composite = new Composite( container, SWT.NONE );
+        Composite container = (Composite) super.createDialogArea(parent);
+        Composite composite = new Composite(container, SWT.NONE);
 
-        if ( optionalEnabled )
+        if (optionalEnabled)
         {
-            new Label( composite, SWT.NONE ); //Spacer
-            btnOptional = new Button( composite, SWT.CHECK );
-            btnOptional.setText( "Optional" );
+            new Label(composite, SWT.NONE); //Spacer
+            btnOptional = new Button(composite, SWT.CHECK);
+            btnOptional.setText("Optional");
         }
 
-        Label lblVersionRange = new Label( composite, SWT.NONE );
-        lblVersionRange.setText( "Version Range:" );
-        Group group = new Group( composite, SWT.BORDER );
+        Label lblVersionRange = new Label(composite, SWT.NONE);
+        lblVersionRange.setText("Version Range:");
+        Group group = new Group(composite, SWT.BORDER);
 
-        pnlVersionRange = new VersionRangeComponent( group, SWT.NONE );
+        pnlVersionRange = new VersionRangeComponent(group, SWT.NONE);
 
         // Initialize
-        if ( selectedVersions != null )
+        if (selectedVersions != null)
         {
-            pnlVersionRange.setVersions( selectedVersions );
+            pnlVersionRange.setVersions(selectedVersions);
         }
 
-        if ( optionalEnabled )
+        if (optionalEnabled)
         {
-            btnOptional.setSelection( optional );
+            btnOptional.setSelection(optional);
             updateButtons();
         }
 
         // Hookup Listeners
-        pnlVersionRange.addVersionChangeListener( new VersionsChangeListener()
+        pnlVersionRange.addVersionChangeListener(new VersionsChangeListener()
         {
-            public void versionsChanged( VersionRange range )
+            public void versionsChanged(VersionRange range)
             {
                 selectedVersions = range;
                 updateButtons();
             }
-        } );
-        pnlVersionRange.addValidationListener( new IValidationListener()
+        });
+        pnlVersionRange.addValidationListener(new IValidationListener()
         {
-            public void validationMessage( String message, int level )
+            public void validationMessage(String message, int level)
             {
-                setMessage( message, level );
+                setMessage(message, level);
                 updateButtons();
             }
-        } );
+        });
 
-        if ( optionalEnabled )
+        if (optionalEnabled)
         {
-            btnOptional.addSelectionListener( new SelectionAdapter()
+            btnOptional.addSelectionListener(new SelectionAdapter()
             {
-                public void widgetSelected( SelectionEvent e )
+                public void widgetSelected(SelectionEvent e)
                 {
                     optional = btnOptional.getSelection();
                 }
-            } );
+            });
         }
 
         // Layout
-        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        GridLayout layout = new GridLayout( 2, false );
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        GridLayout layout = new GridLayout(2, false);
         layout.verticalSpacing = 10;
         layout.horizontalSpacing = 10;
-        composite.setLayout( layout );
+        composite.setLayout(layout);
 
-        lblVersionRange.setLayoutData( new GridData( SWT.LEFT, SWT.TOP, false, false ) );
-        group.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        group.setLayout( new FillLayout() );
+        lblVersionRange.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+        group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        group.setLayout(new FillLayout());
 
         return container;
     }
 
-
     @Override
-    protected void elementSelected( E selection )
+    protected void elementSelected(E selection)
     {
-        if ( selection != null )
+        if (selection != null)
         {
             Version version = selection.getVersion();
             selectedVersions = ModelHelper.getDefaultRange(version);
-            pnlVersionRange.setVersions( selectedVersions );
+            pnlVersionRange.setVersions(selectedVersions);
         }
     }
 
-
     @Override
     protected synchronized boolean canComplete()
     {
         return super.canComplete() && selectedVersions != null;
     }
 
-
     public VersionRange getSelectedVersions()
     {
         return selectedVersions;
     }
 
-
-    public void setVersions( VersionRange versions )
+    public void setVersions(VersionRange versions)
     {
         selectedVersions = versions;
-        if ( pnlVersionRange != null && !pnlVersionRange.isDisposed() )
+        if (pnlVersionRange != null && !pnlVersionRange.isDisposed())
         {
-            pnlVersionRange.setVersions( versions );
+            pnlVersionRange.setVersions(versions);
             updateButtons();
         }
     }
 
-
     public boolean isOptional()
     {
         return optional;
     }
 
-
-    public void setOptional( boolean optional )
+    public void setOptional(boolean optional)
     {
         this.optional = optional;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/OverviewForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/OverviewForm.java
index d1c08f5..aa061e0 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/OverviewForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/OverviewForm.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
@@ -31,7 +30,6 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-
 /**
  * @author dave
  *
@@ -41,21 +39,19 @@
     public static final String PAGE_ID = "overview";
     private ISigilProjectModel sigil;
 
-
-    public OverviewForm( SigilProjectEditorPart editor, ISigilProjectModel sigil )
+    public OverviewForm(SigilProjectEditorPart editor, ISigilProjectModel sigil)
     {
-        super( editor, PAGE_ID, "Overview" );
+        super(editor, PAGE_ID, "Overview");
         this.sigil = sigil;
     }
 
-
     @Override
-    protected void createFormContent( IManagedForm managedForm )
+    protected void createFormContent(IManagedForm managedForm)
     {
         FormToolkit toolkit = managedForm.getToolkit();
 
         ScrolledForm form = managedForm.getForm();
-        form.setText( "Overview" );
+        form.setText("Overview");
 
         Composite body = form.getBody();
         TableWrapLayout layout = new TableWrapLayout();
@@ -65,28 +61,28 @@
         layout.rightMargin = 10;
         layout.numColumns = 2;
         layout.horizontalSpacing = 10;
-        body.setLayout( layout );
-        body.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+        body.setLayout(layout);
+        body.setLayoutData(new TableWrapData(TableWrapData.FILL));
 
-        Composite left = toolkit.createComposite( body );
+        Composite left = toolkit.createComposite(body);
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        left.setLayout( layout );
-        left.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+        left.setLayout(layout);
+        left.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
 
-        Composite right = toolkit.createComposite( body );
+        Composite right = toolkit.createComposite(body);
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        right.setLayout( layout );
-        right.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+        right.setLayout(layout);
+        right.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
 
         try
         {
-            GeneralInfoSection general = new GeneralInfoSection( this, left, sigil );
-            managedForm.addPart( general );
+            GeneralInfoSection general = new GeneralInfoSection(this, left, sigil);
+            managedForm.addPart(general);
 
-            ContentSummarySection content = new ContentSummarySection( this, right, sigil );
-            managedForm.addPart( content );
+            ContentSummarySection content = new ContentSummarySection(this, right, sigil);
+            managedForm.addPart(content);
 
             // XXX-FELIX
             // commented out due to removal of runtime newton integration
@@ -94,12 +90,12 @@
             //TestingSection testing = new TestingSection(this, right, newton);
             //managedForm.addPart(testing);
 
-            ToolsSection tools = new ToolsSection( this, right, sigil );
-            managedForm.addPart( tools );
+            ToolsSection tools = new ToolsSection(this, right, sigil);
+            managedForm.addPart(tools);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to create overview form", e );
+            SigilCore.error("Failed to create overview form", e);
         }
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PackageExportDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PackageExportDialog.java
index 60f9e8b..b44eb5f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PackageExportDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PackageExportDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.common.osgi.VersionTable;
 import org.eclipse.jface.viewers.IContentProvider;
 import org.eclipse.jface.viewers.ViewerFilter;
@@ -32,57 +31,51 @@
 import org.eclipse.swt.widgets.Text;
 import org.osgi.framework.Version;
 
-
 public class PackageExportDialog extends ResourceSelectDialog
 {
 
     private Text versionText;
     private Version version;
 
-
-    public PackageExportDialog( Shell parentShell, String title, IContentProvider content, ViewerFilter filter,
-        Object scope )
+    public PackageExportDialog(Shell parentShell, String title, IContentProvider content, ViewerFilter filter, Object scope)
     {
-        super( parentShell, content, filter, scope, title, "Package Name:", true );
+        super(parentShell, content, filter, scope, title, "Package Name:", true);
     }
 
-
     @Override
-    protected void createCustom( Composite body )
+    protected void createCustom(Composite body)
     {
-        Label l = new Label( body, SWT.NONE );
-        l.setText( "Version:" );
-        versionText = new Text( body, SWT.BORDER );
-        versionText.addKeyListener( new KeyAdapter()
+        Label l = new Label(body, SWT.NONE);
+        l.setText("Version:");
+        versionText = new Text(body, SWT.BORDER);
+        versionText.addKeyListener(new KeyAdapter()
         {
             @Override
-            public void keyReleased( KeyEvent e )
+            public void keyReleased(KeyEvent e)
             {
                 try
                 {
-                    version = VersionTable.getVersion( versionText.getText() );
-                    setErrorMessage( null );
+                    version = VersionTable.getVersion(versionText.getText());
+                    setErrorMessage(null);
                 }
-                catch ( IllegalArgumentException ex )
+                catch (IllegalArgumentException ex)
                 {
-                    setErrorMessage( "Invalid version" );
+                    setErrorMessage("Invalid version");
                 }
             }
-        } );
-        if ( version != null )
+        });
+        if (version != null)
         {
-            versionText.setText( version.toString() );
+            versionText.setText(version.toString());
         }
     }
 
-
     public Version getVersion()
     {
         return version;
     }
 
-
-    public void setVersion( Version version )
+    public void setVersion(Version version)
     {
         this.version = version;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectLabelProvider.java
index 6eb6e4f..e90b342 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectLabelProvider.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.io.InputStream;
 
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
@@ -40,7 +39,6 @@
 import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.widgets.Widget;
 
-
 public class ProjectLabelProvider extends DefaultLabelProvider implements IBaseLabelProvider
 {
 
@@ -48,50 +46,48 @@
     private final ImageRegistry registry;
     private final IDependencyChecker checker;
 
-
-    public ProjectLabelProvider( Widget parent, ImageRegistry registry )
+    public ProjectLabelProvider(Widget parent, ImageRegistry registry)
     {
-        this( parent, registry, null );
+        this(parent, registry, null);
     }
 
-
-    public ProjectLabelProvider( Widget parent, ImageRegistry registry, IDependencyChecker checker )
+    public ProjectLabelProvider(Widget parent, ImageRegistry registry, IDependencyChecker checker)
     {
         this.parent = parent;
         this.registry = registry;
         this.checker = checker;
     }
 
-
-    public Image getImage( Object element )
+    public Image getImage(Object element)
     {
         Image result = null;
-        if ( element instanceof ISigilBundle || element instanceof IRequiredBundle
-            || element instanceof IBundleModelElement )
+        if (element instanceof ISigilBundle || element instanceof IRequiredBundle
+            || element instanceof IBundleModelElement)
         {
             result = findBundle();
         }
-        else if ( element instanceof IPackageImport )
+        else if (element instanceof IPackageImport)
         {
-            if ( checker != null )
+            if (checker != null)
             {
-                result = checker.isSatisfied( ( IPackageImport ) element ) ? findPackage() : findPackageError();
+                result = checker.isSatisfied((IPackageImport) element) ? findPackage()
+                    : findPackageError();
             }
             else
             {
                 result = findPackage();
             }
         }
-        else if ( element instanceof IPackageExport )
+        else if (element instanceof IPackageExport)
         {
             result = findPackage();
         }
-        else if ( element instanceof IPackageFragmentRoot )
+        else if (element instanceof IPackageFragmentRoot)
         {
-            IPackageFragmentRoot root = ( IPackageFragmentRoot ) element;
+            IPackageFragmentRoot root = (IPackageFragmentRoot) element;
             try
             {
-                if ( root.getKind() == IPackageFragmentRoot.K_SOURCE )
+                if (root.getKind() == IPackageFragmentRoot.K_SOURCE)
                 {
                     result = findPackage();
                 }
@@ -100,12 +96,12 @@
                     result = findBundle();
                 }
             }
-            catch ( JavaModelException e )
+            catch (JavaModelException e)
             {
-                SigilCore.error( "Failed to inspect package fragment root", e );
+                SigilCore.error("Failed to inspect package fragment root", e);
             }
         }
-        else if ( element instanceof IClasspathEntry )
+        else if (element instanceof IClasspathEntry)
         {
             result = findPackage();
         }
@@ -113,113 +109,109 @@
         return result;
     }
 
-
-    public String getText( Object element )
+    public String getText(Object element)
     {
-        if ( element instanceof ISigilBundle )
+        if (element instanceof ISigilBundle)
         {
-            ISigilBundle bundle = ( ISigilBundle ) element;
+            ISigilBundle bundle = (ISigilBundle) element;
             return bundle.getBundleInfo().getSymbolicName();
         }
 
-        if ( element instanceof IRequiredBundle )
+        if (element instanceof IRequiredBundle)
         {
-            IRequiredBundle req = ( IRequiredBundle ) element;
+            IRequiredBundle req = (IRequiredBundle) element;
             return req.getSymbolicName() + " " + req.getVersions();
         }
 
-        if ( element instanceof IPackageImport )
+        if (element instanceof IPackageImport)
         {
-            IPackageImport req = ( IPackageImport ) element;
+            IPackageImport req = (IPackageImport) element;
             return req.getPackageName() + " " + req.getVersions();
         }
 
-        if ( element instanceof IPackageExport )
+        if (element instanceof IPackageExport)
         {
-            IPackageExport pe = ( IPackageExport ) element;
+            IPackageExport pe = (IPackageExport) element;
             return pe.getPackageName() + " " + pe.getVersion();
         }
 
-        if ( element instanceof IResource )
+        if (element instanceof IResource)
         {
-            IResource resource = ( IResource ) element;
+            IResource resource = (IResource) element;
             return resource.getName();
         }
 
-        if ( element instanceof IPackageFragment )
+        if (element instanceof IPackageFragment)
         {
-            IPackageFragment f = ( IPackageFragment ) element;
+            IPackageFragment f = (IPackageFragment) element;
             return f.getElementName();
         }
 
-        if ( element instanceof IPackageFragmentRoot )
+        if (element instanceof IPackageFragmentRoot)
         {
-            IPackageFragmentRoot f = ( IPackageFragmentRoot ) element;
+            IPackageFragmentRoot f = (IPackageFragmentRoot) element;
             try
             {
                 return f.getUnderlyingResource().getName();
             }
-            catch ( JavaModelException e )
+            catch (JavaModelException e)
             {
                 return "unknown";
             }
         }
 
-        if ( element instanceof IClasspathEntry )
+        if (element instanceof IClasspathEntry)
         {
-            IClasspathEntry cp = ( IClasspathEntry ) element;
+            IClasspathEntry cp = (IClasspathEntry) element;
             return cp.getPath().toString();
         }
 
         return element.toString();
     }
 
-
     private Image findPackage()
     {
-        Image image = registry.get( "package" );
+        Image image = registry.get("package");
 
-        if ( image == null )
+        if (image == null)
         {
-            image = loadImage( "icons/package_obj.png" );
-            registry.put( "package", image );
+            image = loadImage("icons/package_obj.png");
+            registry.put("package", image);
         }
 
         return image;
     }
 
-
     private Image findPackageError()
     {
-        Image image = registry.get( "package_error" );
-        if ( image == null )
+        Image image = registry.get("package_error");
+        if (image == null)
         {
-            image = loadImage( "icons/package_obj_error.gif" );
-            registry.put( "package_error", image );
+            image = loadImage("icons/package_obj_error.gif");
+            registry.put("package_error", image);
         }
         return image;
     }
 
-
     private Image findBundle()
     {
-        Image image = registry.get( "bundle" );
+        Image image = registry.get("bundle");
 
-        if ( image == null )
+        if (image == null)
         {
-            image = loadImage( "icons/jar_obj.png" );
-            registry.put( "bundle", image );
+            image = loadImage("icons/jar_obj.png");
+            registry.put("bundle", image);
         }
 
         return image;
     }
 
-
-    private Image loadImage( String resource )
+    private Image loadImage(String resource)
     {
-        InputStream in = ProjectLabelProvider.class.getClassLoader().getResourceAsStream( resource );
-        ImageData data = new ImageData( in );
-        return new Image( parent.getDisplay(), data );
+        InputStream in = ProjectLabelProvider.class.getClassLoader().getResourceAsStream(
+            resource);
+        ImageData data = new ImageData(in);
+        return new Image(parent.getDisplay(), data);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectTableViewer.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectTableViewer.java
index 583b198..674ea0e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectTableViewer.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectTableViewer.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.Set;
 
 import org.apache.felix.sigil.common.model.IModelElement;
@@ -28,35 +27,30 @@
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.widgets.Table;
 
-
 public class ProjectTableViewer extends TableViewer
 {
 
     private ModelLabelProvider labelProvider;
 
-
-    public ProjectTableViewer( Table table )
+    public ProjectTableViewer(Table table)
     {
-        super( table );
+        super(table);
         labelProvider = new ModelLabelProvider();
-        setLabelProvider( labelProvider );
+        setLabelProvider(labelProvider);
     }
 
-
     @Override
-    public void setContentProvider( IContentProvider provider )
+    public void setContentProvider(IContentProvider provider)
     {
-        super.setContentProvider( provider );
-        setInput( getTable() );
+        super.setContentProvider(provider);
+        setInput(getTable());
     }
 
-
-    public void setUnresolvedElements( Set<? extends IModelElement> elements )
+    public void setUnresolvedElements(Set<? extends IModelElement> elements)
     {
-        labelProvider.setUnresolvedElements( elements );
+        labelProvider.setUnresolvedElements(elements);
     }
 
-
     @Override
     public ModelLabelProvider getLabelProvider()
     {
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PropertiesForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PropertiesForm.java
index 66a98de..8662fef 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PropertiesForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PropertiesForm.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.eclipse.jdt.internal.ui.JavaPlugin;
 import org.eclipse.jdt.internal.ui.propertiesfileeditor.IPropertiesFilePartitions;
@@ -27,27 +26,25 @@
 import org.eclipse.jdt.ui.text.JavaTextTools;
 import org.eclipse.jface.preference.IPreferenceStore;
 
-
 @SuppressWarnings("restriction")
 public class PropertiesForm extends SigilSourcePage
 {
 
     public static final String PAGE_ID = "properties";
 
-
-    public PropertiesForm( SigilProjectEditorPart editor, ISigilProjectModel project )
+    public PropertiesForm(SigilProjectEditorPart editor, ISigilProjectModel project)
     {
-        super( PAGE_ID );
+        super(PAGE_ID);
         JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools();
         IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
-        setPreferenceStore( store );
-        setSourceViewerConfiguration( new PropertiesFileSourceViewerConfiguration( textTools.getColorManager(), store,
-            this, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING ) );
+        setPreferenceStore(store);
+        setSourceViewerConfiguration(new PropertiesFileSourceViewerConfiguration(
+            textTools.getColorManager(), store, this,
+            IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING));
         /*IFileEditorInput fileInput = (IFileEditorInput) editor.getEditorInput();
         this.setDocumentProvider(fileInput);*/
     }
 
-
     @Override
     public boolean isSaveAsAllowed()
     {
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/RequiresBundleSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/RequiresBundleSection.java
index e4f692c..400795e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/RequiresBundleSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/RequiresBundleSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.Iterator;
 import java.util.Set;
 
@@ -42,123 +41,116 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
-
 public class RequiresBundleSection extends BundleDependencySection
 {
 
-    public RequiresBundleSection( SigilPage page, Composite parent, ISigilProjectModel project,
-        Set<IModelElement> unresolvedElements ) throws CoreException
+    public RequiresBundleSection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedElements) throws CoreException
     {
-        super( page, parent, project, unresolvedElements );
+        super(page, parent, project, unresolvedElements);
     }
 
-
     @Override
     protected String getTitle()
     {
         return "Requires Bundles";
     }
 
-
     @Override
-    protected Label createLabel( Composite parent, FormToolkit toolkit )
+    protected Label createLabel(Composite parent, FormToolkit toolkit)
     {
-        return toolkit.createLabel( parent, "Specify which bundles this bundle depends on." );
+        return toolkit.createLabel(parent,
+            "Specify which bundles this bundle depends on.");
     }
 
-
     @Override
     protected IContentProvider getContentProvider()
     {
         return new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
                 return getBundle().getBundleInfo().getRequiredBundles().toArray();
             }
         };
     }
 
-
     protected ISigilBundle getBundle()
     {
         return getProjectModel().getBundle();
     }
 
-
     @Override
     protected void handleAdd()
     {
         try
         {
             NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog(
-                getSection().getShell(), "Add Required Bundle", getProjectModel(), null, getBundle().getBundleInfo()
-                    .getRequiredBundles() );
+                getSection().getShell(), "Add Required Bundle", getProjectModel(), null,
+                getBundle().getBundleInfo().getRequiredBundles());
 
-            if ( dialog.open() == Window.OK )
+            if (dialog.open() == Window.OK)
             {
-                IRequiredBundle required = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
-                required.setSymbolicName( dialog.getSelectedName() );
-                required.setVersions( dialog.getSelectedVersions() );
-                required.setOptional( dialog.isOptional() );
+                IRequiredBundle required = ModelElementFactory.getInstance().newModelElement(
+                    IRequiredBundle.class);
+                required.setSymbolicName(dialog.getSelectedName());
+                required.setVersions(dialog.getSelectedVersions());
+                required.setOptional(dialog.isOptional());
 
-                getBundle().getBundleInfo().addRequiredBundle( required );
+                getBundle().getBundleInfo().addRequiredBundle(required);
                 refresh();
                 markDirty();
             }
         }
-        catch ( ModelElementFactoryException e )
+        catch (ModelElementFactoryException e)
         {
-            SigilCore.error( "Failed to build required bundle", e );
+            SigilCore.error("Failed to build required bundle", e);
         }
     }
 
-
     @SuppressWarnings("unchecked")
     @Override
     protected void handleEdit()
     {
-        IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+        IStructuredSelection selection = (IStructuredSelection) getSelection();
 
         boolean changed = false;
 
-        if ( !selection.isEmpty() )
+        if (!selection.isEmpty())
         {
-            for ( Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext(); )
+            for (Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext();)
             {
                 IRequiredBundle requiredBundle = i.next();
-                NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper
-                    .createRequiredBundleDialog( getSection().getShell(), "Edit Imported Package", getProjectModel(),
-                        requiredBundle, getBundle().getBundleInfo().getRequiredBundles() );
-                if ( dialog.open() == Window.OK )
+                NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog(
+                    getSection().getShell(), "Edit Imported Package", getProjectModel(),
+                    requiredBundle, getBundle().getBundleInfo().getRequiredBundles());
+                if (dialog.open() == Window.OK)
                 {
                     changed = true;
-                    requiredBundle.setSymbolicName( dialog.getSelectedName() );
-                    requiredBundle.setVersions( dialog.getSelectedVersions() );
-                    requiredBundle.setOptional( dialog.isOptional() );
+                    requiredBundle.setSymbolicName(dialog.getSelectedName());
+                    requiredBundle.setVersions(dialog.getSelectedVersions());
+                    requiredBundle.setOptional(dialog.isOptional());
                 }
             }
         }
 
-        if ( changed )
+        if (changed)
         {
             refresh();
             markDirty();
         }
     }
 
-
     @SuppressWarnings("unchecked")
     @Override
     protected void handleRemoved()
     {
-        IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+        IStructuredSelection selection = (IStructuredSelection) getSelection();
 
-        if ( !selection.isEmpty() )
+        if (!selection.isEmpty())
         {
-            for ( Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext(); )
+            for (Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext();)
             {
-                getBundle().getBundleInfo().removeRequiredBundle( i.next() );
+                getBundle().getBundleInfo().removeRequiredBundle(i.next());
             }
 
             refresh();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceBuildSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceBuildSection.java
index 7965602..fe7678b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceBuildSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceBuildSection.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-
 import org.apache.felix.sigil.common.config.Resource;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.eclipse.SigilCore;
@@ -54,78 +52,73 @@
 import org.eclipse.ui.model.BaseWorkbenchContentProvider;
 import org.eclipse.ui.model.WorkbenchLabelProvider;
 
-
 /**
  * @author dave
  *
  */
-public class ResourceBuildSection extends AbstractResourceSection implements ICheckStateListener,
-    IResourceChangeListener, IPropertyChangeListener
+public class ResourceBuildSection extends AbstractResourceSection implements ICheckStateListener, IResourceChangeListener, IPropertyChangeListener
 {
 
     private ExcludedResourcesFilter resourcesFilter;
 
-
     /**
      * @param page
      * @param parent
      * @param project
      * @throws CoreException 
      */
-    public ResourceBuildSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public ResourceBuildSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
     @Override
-    protected void createSection( Section section, FormToolkit toolkit )
+    protected void createSection(Section section, FormToolkit toolkit)
     {
-        setTitle( "Resources" );
+        setTitle("Resources");
 
-        Composite body = createTableWrapBody( 1, toolkit );
+        Composite body = createTableWrapBody(1, toolkit);
 
-        toolkit.createLabel( body, "Specify which resources are included in the bundle." );
+        toolkit.createLabel(body, "Specify which resources are included in the bundle.");
 
-        tree = toolkit.createTree( body, SWT.CHECK | SWT.BORDER );
-        Link link = new Link( body, SWT.WRAP );
-        link
-            .setText( "Some resources may be filtered according to preferences. <a href=\"excludedResourcePrefs\">Click here</a> to edit the list of exclusions." );
+        tree = toolkit.createTree(body, SWT.CHECK | SWT.BORDER);
+        Link link = new Link(body, SWT.WRAP);
+        link.setText("Some resources may be filtered according to preferences. <a href=\"excludedResourcePrefs\">Click here</a> to edit the list of exclusions.");
 
-        TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB );
+        TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
         data.heightHint = 200;
-        tree.setLayoutData( data );
+        tree.setLayoutData(data);
 
-        viewer = new CheckboxTreeViewer( tree );
+        viewer = new CheckboxTreeViewer(tree);
         IProject base = getProjectModel().getProject();
         viewer.setContentProvider(new BaseWorkbenchContentProvider());
         viewer.setLabelProvider(new WorkbenchLabelProvider());
-        viewer.addCheckStateListener( this );
+        viewer.addCheckStateListener(this);
         resourcesFilter = new ExcludedResourcesFilter();
-        viewer.addFilter( resourcesFilter );
-        viewer.setInput( base );
+        viewer.addFilter(resourcesFilter);
+        viewer.setInput(base);
 
-        link.addListener( SWT.Selection, new Listener()
+        link.addListener(SWT.Selection, new Listener()
         {
-            public void handleEvent( Event event )
+            public void handleEvent(Event event)
             {
-                if ( "excludedResourcePrefs".equals( event.text ) )
+                if ("excludedResourcePrefs".equals(event.text))
                 {
-                    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( getPage().getEditorSite()
-                        .getShell(), SigilCore.EXCLUDED_RESOURCES_PREFERENCES_ID, null, null );
+                    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+                        getPage().getEditorSite().getShell(),
+                        SigilCore.EXCLUDED_RESOURCES_PREFERENCES_ID, null, null);
                     dialog.open();
                 }
             }
-        } );
+        });
 
-        SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener( this );
+        SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener(this);
 
-        startWorkspaceListener( base.getWorkspace() );
+        startWorkspaceListener(base.getWorkspace());
     }
 
-
     @Override
-    public void commit( boolean onSave )
+    public void commit(boolean onSave)
     {
         ISigilBundle bundle = getProjectModel().getBundle();
 
@@ -133,25 +126,25 @@
 
         try
         {
-            SigilUI.runInUISync( new Callable<Void>()
+            SigilUI.runInUISync(new Callable<Void>()
             {
                 public Void call() throws Exception
                 {
-                    for ( Object o : viewer.getCheckedElements() )
+                    for (Object o : viewer.getCheckedElements())
                     {
-                        if ( !viewer.getGrayed( o ) )
+                        if (!viewer.getGrayed(o))
                         {
-                            IResource r = ( IResource ) o;
-                            
-                            getProjectModel().getBundle().addSourcePath( toBldResource(r) );
+                            IResource r = (IResource) o;
+
+                            getProjectModel().getBundle().addSourcePath(toBldResource(r));
                         }
                     }
-                    
+
                     return null;
                 }
-            } );
+            });
 
-            super.commit( onSave );
+            super.commit(onSave);
         }
         catch (Exception e)
         {
@@ -159,43 +152,41 @@
         }
     }
 
-
     @Override
     protected void refreshSelections()
     {
         // zero the state
-        for ( Resource path : getProjectModel().getBundle().getSourcePaths() )
+        for (Resource path : getProjectModel().getBundle().getSourcePaths())
         {
-            IResource r = findResource( new Path(path.getLocalFile()) );
-            if ( r != null )
+            IResource r = findResource(new Path(path.getLocalFile()));
+            if (r != null)
             {
-                viewer.expandToLevel( r, 0 );
-                viewer.setChecked( r, true );
-                viewer.setGrayed( r, false );
-                handleStateChanged( r, true, false, false );
+                viewer.expandToLevel(r, 0);
+                viewer.setChecked(r, true);
+                viewer.setGrayed(r, false);
+                handleStateChanged(r, true, false, false);
             }
             else
             {
-                SigilCore.error( "Unknown path " + path );
+                SigilCore.error("Unknown path " + path);
             }
         }
     }
 
-
     @Override
-    protected void syncResourceModel( IResource element, boolean checked )
+    protected void syncResourceModel(IResource element, boolean checked)
     {
         try
         {
             Resource resource = toBldResource(element);
-            
-            if ( checked )
+
+            if (checked)
             {
-                getProjectModel().getBundle().addSourcePath( resource );
+                getProjectModel().getBundle().addSourcePath(resource);
             }
             else
             {
-                getProjectModel().getBundle().removeSourcePath( resource );
+                getProjectModel().getBundle().removeSourcePath(resource);
             }
 
             markDirty();
@@ -213,28 +204,31 @@
      */
     private Resource toBldResource(IResource element) throws CoreException
     {
-        return getProjectModel().getBldProject().newResource(element.getProjectRelativePath().toString());
+        return getProjectModel().getBldProject().newResource(
+            element.getProjectRelativePath().toString());
     }
 
     private AtomicBoolean disposed = new AtomicBoolean();
-    
+
     @Override
     public void dispose()
     {
-        disposed.set( true );
-        SigilCore.getDefault().getPreferenceStore().removePropertyChangeListener( this );
+        disposed.set(true);
+        SigilCore.getDefault().getPreferenceStore().removePropertyChangeListener(this);
         super.dispose();
     }
 
-
-    public void propertyChange( PropertyChangeEvent event )
+    public void propertyChange(PropertyChangeEvent event)
     {
-        if ( !disposed.get() ) {
+        if (!disposed.get())
+        {
             resourcesFilter.loadExclusions();
-            try {
+            try
+            {
                 viewer.refresh();
             }
-            catch (SWTException e) {
+            catch (SWTException e)
+            {
                 // can happen on dispose
             }
         }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceImportDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceImportDialog.java
index 6cde232..e667941 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceImportDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceImportDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.common.model.ModelElementFactory;
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.osgi.VersionRange;
@@ -31,81 +30,73 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Shell;
 
-
 public class ResourceImportDialog extends ResourceSelectDialog implements VersionsChangeListener
 {
 
     private VersionRangeComponent versions;
     private VersionRange range;
 
-
-    public ResourceImportDialog( Shell parentShell, String title, String label, IContentProvider content,
-        ViewerFilter filter, Object scope )
+    public ResourceImportDialog(Shell parentShell, String title, String label, IContentProvider content, ViewerFilter filter, Object scope)
     {
-        super( parentShell, content, filter, scope, title, label, true );
+        super(parentShell, content, filter, scope, title, label, true);
     }
 
-
     public VersionRange getVersions()
     {
         return range;
     }
 
-
     @Override
-    protected void createCustom( Composite body )
+    protected void createCustom(Composite body)
     {
-        versions = new VersionRangeComponent( body, SWT.BORDER );
-        versions.addVersionChangeListener( this );
-        versions.setVersions( range );
+        versions = new VersionRangeComponent(body, SWT.BORDER);
+        versions.addVersionChangeListener(this);
+        versions.setVersions(range);
 
-        GridData data = new GridData( SWT.LEFT, SWT.TOP, true, true );
+        GridData data = new GridData(SWT.LEFT, SWT.TOP, true, true);
         data.horizontalSpan = 2;
         data.widthHint = 300;
         data.heightHint = 200;
-        versions.setLayoutData( data );
+        versions.setLayoutData(data);
     }
 
-
     @Override
-    protected void selectionChanged( SelectionChangedEvent event )
+    protected void selectionChanged(SelectionChangedEvent event)
     {
-        if ( event.getSelection().isEmpty() )
+        if (event.getSelection().isEmpty())
         {
-            versions.setEnabled( false );
+            versions.setEnabled(false);
         }
         else
         {
-            versions.setEnabled( true );
+            versions.setEnabled(true);
         }
     }
 
-
-    public void versionsChanged( VersionRange range )
+    public void versionsChanged(VersionRange range)
     {
         this.range = range;
-        if ( range == null )
+        if (range == null)
         {
-            setErrorMessage( "Invalid version" );
+            setErrorMessage("Invalid version");
         }
         else
         {
-            setErrorMessage( null );
+            setErrorMessage(null);
         }
     }
 
-
-    public void setVersions( VersionRange range )
+    public void setVersions(VersionRange range)
     {
         this.range = range;
     }
 
-
     public IPackageImport getImport()
     {
-        IPackageImport packageImport = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
-        packageImport.setPackageName( ( String ) getSelected()[0] );
-        packageImport.setVersions( getVersions() );
+        IPackageImport packageImport = ModelElementFactory.getInstance().newModelElement(
+            IPackageImport.class);
+        packageImport.setPackageName((String) getSelected()[0]);
+        packageImport.setVersions(getVersions());
         return packageImport;
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceSelectDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceSelectDialog.java
index 00bb575..7b7740a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceSelectDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceSelectDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
@@ -58,7 +57,6 @@
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 
-
 public class ResourceSelectDialog extends Dialog
 {
 
@@ -69,22 +67,20 @@
     {
         private int check;
 
-
-        public UpdateViewerRunnable( int check )
+        public UpdateViewerRunnable(int check)
         {
             this.check = check;
         }
 
-
         public void run()
         {
-            if ( check == keyCheck.get() )
+            if (check == keyCheck.get())
             {
                 try
                 {
                     viewer.refresh();
                 }
-                catch ( SWTException e )
+                catch (SWTException e)
                 {
                     // discard
                 }
@@ -119,11 +115,9 @@
     private IContentProvider content;
     private ILabelProvider labelProvider;
 
-
-    public ResourceSelectDialog( Shell parentShell, IContentProvider content, ViewerFilter filter, Object scope,
-        String title, String selectionText, boolean isCombo )
+    public ResourceSelectDialog(Shell parentShell, IContentProvider content, ViewerFilter filter, Object scope, String title, String selectionText, boolean isCombo)
     {
-        super( parentShell );
+        super(parentShell);
         this.title = title;
         this.selectionText = selectionText;
         this.content = content;
@@ -132,18 +126,16 @@
         this.isCombo = isCombo;
     }
 
-
-    public void setJob( Job job )
+    public void setJob(Job job)
     {
         this.job = job;
     }
 
-
     public void refreshResources()
     {
         try
         {
-            getShell().getDisplay().asyncExec( new Runnable()
+            getShell().getDisplay().asyncExec(new Runnable()
             {
                 public void run()
                 {
@@ -151,65 +143,63 @@
                     {
                         viewer.refresh();
                     }
-                    catch ( SWTException e )
+                    catch (SWTException e)
                     {
                         // attempt to exec after dialog closed - discard
                     }
                 }
-            } );
+            });
         }
-        catch ( NullPointerException e )
+        catch (NullPointerException e)
         {
             // attempt to exec after dialog closed - discard
         }
-        catch ( SWTException e )
+        catch (SWTException e)
         {
             // attempt to exec after dialog closed - discard
         }
     }
 
-
     /*
      * (non-Javadoc)
      * 
      * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
      */
-    protected void configureShell( Shell shell )
+    protected void configureShell(Shell shell)
     {
-        super.configureShell( shell );
-        if ( title != null )
+        super.configureShell(shell);
+        if (title != null)
         {
-            shell.setText( title );
+            shell.setText(title);
         }
     }
 
-
     @Override
     public void create()
     {
         super.create();
-        if ( getItemCount() == 0 )
+        if (getItemCount() == 0)
         {
-            setErrorMessage( "No resources available" );
-            getButton( IDialogConstants.OK_ID ).setEnabled( false );
+            setErrorMessage("No resources available");
+            getButton(IDialogConstants.OK_ID).setEnabled(false);
         }
         else
         {
-            ISelection selection = selected == null ? EMPTY_SELECTION : new SingletonSelection( selected );
-            setSelected( new SelectionChangedEvent( viewer, selection ), true );
+            ISelection selection = selected == null ? EMPTY_SELECTION
+                : new SingletonSelection(selected);
+            setSelected(new SelectionChangedEvent(viewer, selection), true);
         }
 
-        if ( job != null )
+        if (job != null)
         {
             job.schedule();
         }
     }
 
-
     @Override
     public boolean close()
     {
-        if ( job != null )
+        if (job != null)
         {
             job.cancel();
         }
@@ -217,10 +207,9 @@
         return super.close();
     }
 
-
     private int getItemCount()
     {
-        if ( isCombo )
+        if (isCombo)
         {
             return resourceNameCombo.getItemCount();
         }
@@ -230,135 +219,131 @@
         }
     }
 
-
     @Override
-    protected Control createDialogArea( Composite parent )
+    protected Control createDialogArea(Composite parent)
     {
-        Composite body = ( Composite ) super.createDialogArea( parent );
+        Composite body = (Composite) super.createDialogArea(parent);
 
-        GridLayout layout = ( GridLayout ) body.getLayout();
+        GridLayout layout = (GridLayout) body.getLayout();
         layout.numColumns = 2;
         GridData data;
 
         labelProvider = new ModelLabelProvider();
 
-        Label l = new Label( body, SWT.LEFT );
-        l.setText( selectionText );
-        data = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
-        if ( !isCombo )
+        Label l = new Label(body, SWT.LEFT);
+        l.setText(selectionText);
+        data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+        if (!isCombo)
         {
             data.horizontalSpan = 2;
         }
-        l.setLayoutData( data );
+        l.setLayoutData(data);
 
-        if ( isCombo )
+        if (isCombo)
         {
-            createCombo( body );
+            createCombo(body);
         }
         else
         {
-            createTable( body );
+            createTable(body);
         }
 
-        viewer.addFilter( filter );
-        viewer.setContentProvider( content );
-        viewer.setLabelProvider( getLabelProvider() );
-        viewer.setComparator( new ViewerComparator() );
-        viewer.setInput( scope );
+        viewer.addFilter(filter);
+        viewer.setContentProvider(content);
+        viewer.setLabelProvider(getLabelProvider());
+        viewer.setComparator(new ViewerComparator());
+        viewer.setInput(scope);
 
-        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        viewer.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
-                setSelected( event, false );
+                setSelected(event, false);
             }
-        } );
-        createCustom( body );
+        });
+        createCustom(body);
 
-        errorMessageText = new Text( body, SWT.READ_ONLY | SWT.WRAP );
-        data = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL );
+        errorMessageText = new Text(body, SWT.READ_ONLY | SWT.WRAP);
+        data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
         data.horizontalSpan = 2;
-        errorMessageText.setLayoutData( data );
-        errorMessageText.setBackground( errorMessageText.getDisplay().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
-        setErrorMessage( errorMessage );
+        errorMessageText.setLayoutData(data);
+        errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(
+            SWT.COLOR_WIDGET_BACKGROUND));
+        setErrorMessage(errorMessage);
 
         return body;
     }
 
-
-    protected void createCustom( Composite body )
+    protected void createCustom(Composite body)
     {
     }
 
-
-    private void createCombo( Composite body )
+    private void createCombo(Composite body)
     {
-        resourceNameCombo = new Combo( body, SWT.SINGLE | SWT.BORDER );
-        GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+        resourceNameCombo = new Combo(body, SWT.SINGLE | SWT.BORDER);
+        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
         data.widthHint = 200;
-        resourceNameCombo.setLayoutData( data );
+        resourceNameCombo.setLayoutData(data);
 
-        viewer = new ComboViewer( resourceNameCombo );
+        viewer = new ComboViewer(resourceNameCombo);
     }
 
-
-    private void createTable( Composite body )
+    private void createTable(Composite body)
     {
-        final Text txtFilter = new Text( body, SWT.BORDER );
-        GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+        final Text txtFilter = new Text(body, SWT.BORDER);
+        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
         data.horizontalSpan = 2;
         data.widthHint = 400;
-        txtFilter.setLayoutData( data );
+        txtFilter.setLayoutData(data);
 
-        resourceNameTable = new Table( body, SWT.MULTI | SWT.BORDER );
-        data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+        resourceNameTable = new Table(body, SWT.MULTI | SWT.BORDER);
+        data = new GridData(GridData.HORIZONTAL_ALIGN_END);
         data.widthHint = 400;
         data.heightHint = 400;
-        resourceNameTable.setLayoutData( data );
+        resourceNameTable.setLayoutData(data);
 
-        viewer = new TableViewer( resourceNameTable );
+        viewer = new TableViewer(resourceNameTable);
 
-        txtFilter.addKeyListener( new KeyAdapter()
+        txtFilter.addKeyListener(new KeyAdapter()
         {
             @Override
-            public void keyReleased( KeyEvent e )
+            public void keyReleased(KeyEvent e)
             {
-                switch ( e.keyCode )
+                switch (e.keyCode)
                 {
                     case SWT.ARROW_UP:
-                        scrollTable( -1 );
+                        scrollTable(-1);
                         break;
                     case SWT.ARROW_DOWN:
-                        scrollTable( +1 );
+                        scrollTable(+1);
                         break;
                     default:
-                        Runnable r = new UpdateViewerRunnable( keyCheck.incrementAndGet() );
-                        background.schedule( r, 100, TimeUnit.MILLISECONDS );
+                        Runnable r = new UpdateViewerRunnable(keyCheck.incrementAndGet());
+                        background.schedule(r, 100, TimeUnit.MILLISECONDS);
                         break;
                 }
             }
-        } );
+        });
 
         ViewerFilter filter = new ViewerFilter()
         {
             @Override
-            public boolean select( Viewer viewer, Object parentElement, Object element )
+            public boolean select(Viewer viewer, Object parentElement, Object element)
             {
-                return getLabelProvider().getText( element ).startsWith( txtFilter.getText() );
+                return getLabelProvider().getText(element).startsWith(txtFilter.getText());
             }
         };
 
-        viewer.addFilter( filter );
+        viewer.addFilter(filter);
     }
 
-
-    private void scrollTable( int delta )
+    private void scrollTable(int delta)
     {
         int i = resourceNameTable.getSelectionIndex();
 
-        if ( i == -1 )
+        if (i == -1)
         {
-            if ( delta < 0 )
+            if (delta < 0)
             {
                 i = resourceNameTable.getItemCount() - 1;
             }
@@ -372,87 +357,80 @@
             i += delta;
         }
 
-        if ( i > -1 && i < resourceNameTable.getItemCount() )
+        if (i > -1 && i < resourceNameTable.getItemCount())
         {
-            Item item = resourceNameTable.getItem( i );
-            resourceNameTable.select( i );
-            selected = new Object[]
-                { item.getData() };
-            ISelection selection = new SingletonSelection( selected );
-            selectionChanged( new SelectionChangedEvent( viewer, selection ) );
-            viewer.reveal( selected );
+            Item item = resourceNameTable.getItem(i);
+            resourceNameTable.select(i);
+            selected = new Object[] { item.getData() };
+            ISelection selection = new SingletonSelection(selected);
+            selectionChanged(new SelectionChangedEvent(viewer, selection));
+            viewer.reveal(selected);
         }
     }
 
-
-    private void setSelected( SelectionChangedEvent event, boolean reveal )
+    private void setSelected(SelectionChangedEvent event, boolean reveal)
     {
-        if ( event.getSelection().isEmpty() )
+        if (event.getSelection().isEmpty())
         {
             selected = null;
-            setErrorMessage( "No resource selected" );
+            setErrorMessage("No resource selected");
         }
         else
         {
-            selected = ( ( IStructuredSelection ) event.getSelection() ).toArray();
-            setErrorMessage( null );
+            selected = ((IStructuredSelection) event.getSelection()).toArray();
+            setErrorMessage(null);
         }
 
-        selectionChanged( event );
+        selectionChanged(event);
 
-        if ( reveal && !event.getSelection().isEmpty() )
+        if (reveal && !event.getSelection().isEmpty())
         {
-            if ( resourceNameCombo != null )
+            if (resourceNameCombo != null)
             {
-                IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
-                resourceNameCombo.select( resourceNameCombo.indexOf( ( String ) sel.getFirstElement() ) );
+                IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+                resourceNameCombo.select(resourceNameCombo.indexOf((String) sel.getFirstElement()));
             }
             else
             {
-                viewer.setSelection( event.getSelection(), true );
+                viewer.setSelection(event.getSelection(), true);
             }
         }
     }
 
-
     protected ILabelProvider getLabelProvider()
     {
         return labelProvider;
     }
 
-
     public Object[] getSelected()
     {
         return selected;
     }
 
-
-    public void setSelected( Object[] selected )
+    public void setSelected(Object[] selected)
     {
         this.selected = selected;
     }
 
-
-    protected void selectionChanged( SelectionChangedEvent event )
+    protected void selectionChanged(SelectionChangedEvent event)
     {
     }
 
-
-    public void setErrorMessage( String errorMessage )
+    public void setErrorMessage(String errorMessage)
     {
         this.errorMessage = errorMessage;
-        if ( errorMessageText != null && !errorMessageText.isDisposed() )
+        if (errorMessageText != null && !errorMessageText.isDisposed())
         {
-            errorMessageText.setText( errorMessage == null ? " \n " : errorMessage );
+            errorMessageText.setText(errorMessage == null ? " \n " : errorMessage);
             boolean hasError = errorMessage != null
-                && ( StringConverter.removeWhiteSpaces( errorMessage ) ).length() > 0;
-            errorMessageText.setEnabled( hasError );
-            errorMessageText.setVisible( hasError );
+                && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
+            errorMessageText.setEnabled(hasError);
+            errorMessageText.setVisible(hasError);
             errorMessageText.getParent().update();
-            Control ok = getButton( IDialogConstants.OK_ID );
-            if ( ok != null )
+            Control ok = getButton(IDialogConstants.OK_ID);
+            if (ok != null)
             {
-                ok.setEnabled( !hasError );
+                ok.setEnabled(!hasError);
             }
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilProjectEditorPart.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilProjectEditorPart.java
index d415457..8992870 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilProjectEditorPart.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilProjectEditorPart.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.lang.reflect.InvocationTargetException;
 import java.util.Collections;
 import java.util.HashSet;
@@ -62,68 +61,68 @@
 import org.eclipse.ui.forms.editor.FormEditor;
 import org.eclipse.ui.forms.editor.IFormPage;
 
-
 public class SigilProjectEditorPart extends FormEditor implements IResourceChangeListener
 {
 
-    private final Set<IModelElement> unresolvedElements = Collections.synchronizedSet( new HashSet<IModelElement>() );
+    private final Set<IModelElement> unresolvedElements = Collections.synchronizedSet(new HashSet<IModelElement>());
     private ISigilProjectModel project;
     private ISigilProjectModel tempProject;
     private volatile boolean saving = false;
     private int dependenciesPageIndex;
 
-    private Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+    private Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(
+        ISharedImages.IMG_OBJS_ERROR_TSK);
 
     private PropertiesForm textPage;
 
-
     public IProject getProject()
     {
-        IFileEditorInput fileInput = ( IFileEditorInput ) getEditorInput();
+        IFileEditorInput fileInput = (IFileEditorInput) getEditorInput();
         return fileInput.getFile().getProject();
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void doSave( IProgressMonitor monitor )
+    public void doSave(IProgressMonitor monitor)
     {
-        monitor.beginTask( "Saving", IProgressMonitor.UNKNOWN );
+        monitor.beginTask("Saving", IProgressMonitor.UNKNOWN);
         try
         {
             saving = true;
-            new ProgressMonitorDialog( getSite().getShell() ).run( true, true, new IRunnableWithProgress()
-            {
-                public void run( IProgressMonitor monitor ) throws InvocationTargetException,
-                    InterruptedException
+            new ProgressMonitorDialog(getSite().getShell()).run(true, true,
+                new IRunnableWithProgress()
                 {
-                    try
+                    public void run(IProgressMonitor monitor)
+                        throws InvocationTargetException, InterruptedException
                     {
-                        if ( doInternalSave(monitor) ) {
-                            project.setBundle( null );
-                            tempProject.setBundle(null);
-                            project.rebuildDependencies(monitor);
-                            refreshAllPages();
-                        }
+                        try
+                        {
+                            if (doInternalSave(monitor))
+                            {
+                                project.setBundle(null);
+                                tempProject.setBundle(null);
+                                project.rebuildDependencies(monitor);
+                                refreshAllPages();
+                            }
 
-                        monitor.done();
+                            monitor.done();
+                        }
+                        catch (CoreException e)
+                        {
+                            throw new InvocationTargetException(e);
+                        }
                     }
-                    catch ( CoreException e )
-                    {
-                        throw new InvocationTargetException( e );
-                    }
-                }
-            } );
+                });
         }
-        catch ( InvocationTargetException e )
+        catch (InvocationTargetException e)
         {
-            SigilCore.error( "Failed to save " + project, e.getTargetException() );
+            SigilCore.error("Failed to save " + project, e.getTargetException());
         }
-        catch ( InterruptedException e )
+        catch (InterruptedException e)
         {
-            monitor.setCanceled( true );
+            monitor.setCanceled(true);
             return;
         }
         finally
@@ -133,40 +132,38 @@
         monitor.done();
     }
 
-
     private boolean doInternalSave(final IProgressMonitor monitor) throws CoreException
     {
-        if ( textPage.isDirty() )
+        if (textPage.isDirty())
         {
-            SigilUI.runInUISync( new Runnable()
+            SigilUI.runInUISync(new Runnable()
             {
                 public void run()
                 {
-                    textPage.doSave( monitor );
+                    textPage.doSave(monitor);
                 }
-            } );
+            });
             return true;
         }
-        else if ( isDirty() )
+        else if (isDirty())
         {
-            commitPages( true );
-            tempProject.save( monitor, false );
-            SigilUI.runInUISync( new Runnable()
+            commitPages(true);
+            tempProject.save(monitor, false);
+            SigilUI.runInUISync(new Runnable()
             {
                 public void run()
                 {
                     textPage.setInput(getEditorInput());
                     editorDirtyStateChanged();
                 }
-            } );
+            });
             return true;
         }
-        
+
         // ok no changes
         return false;
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
      */
@@ -175,36 +172,35 @@
     {
         try
         {
-            addPage( new OverviewForm( this, tempProject ) );
-            addPage( new ContentsForm( this, tempProject ) );
-            dependenciesPageIndex = addPage( new DependenciesForm( this, tempProject, unresolvedElements ) );
-            addPage( new ExportsForm( this, tempProject ) );
-            textPage = new PropertiesForm( this, tempProject );
-            addPage( textPage, getEditorInput() );
-            setPartName( project.getSymbolicName() );
+            addPage(new OverviewForm(this, tempProject));
+            addPage(new ContentsForm(this, tempProject));
+            dependenciesPageIndex = addPage(new DependenciesForm(this, tempProject,
+                unresolvedElements));
+            addPage(new ExportsForm(this, tempProject));
+            textPage = new PropertiesForm(this, tempProject);
+            addPage(textPage, getEditorInput());
+            setPartName(project.getSymbolicName());
 
             refreshTabImages();
         }
-        catch ( PartInitException e )
+        catch (PartInitException e)
         {
-            SigilCore.error( "Failed to build " + this, e );
+            SigilCore.error("Failed to build " + this, e);
         }
     }
 
-
     protected void refreshTabImages()
     {
-        if ( unresolvedElements.isEmpty() )
+        if (unresolvedElements.isEmpty())
         {
-            setPageImage( dependenciesPageIndex, null );
+            setPageImage(dependenciesPageIndex, null);
         }
         else
         {
-            setPageImage( dependenciesPageIndex, errorImage );
+            setPageImage(dependenciesPageIndex, errorImage);
         }
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.EditorPart#doSaveAs()
      */
@@ -214,7 +210,6 @@
         // save as not allowed
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
      */
@@ -224,20 +219,19 @@
         return false;
     }
 
-
     @Override
     public void dispose()
     {
-        ResourcesPlugin.getWorkspace().removeResourceChangeListener( this );
+        ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
         super.dispose();
     }
 
-
-    public void resourceChanged( IResourceChangeEvent event )
+    public void resourceChanged(IResourceChangeEvent event)
     {
         try
         {
-            switch (event.getType()) {
+            switch (event.getType())
+            {
                 case IResourceChangeEvent.POST_BUILD:
                     handleBuild(event);
                     break;
@@ -246,36 +240,35 @@
                     break;
             }
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            ErrorDialog.openError( getSite().getShell(), "Error", null, e.getStatus() );
+            ErrorDialog.openError(getSite().getShell(), "Error", null, e.getStatus());
         }
     }
 
-
     private void handleBuild(IResourceChangeEvent event) throws CoreException
     {
         refreshView();
     }
 
-
     private void handleChange(IResourceChangeEvent event) throws CoreException
     {
         IResourceDelta delta = event.getDelta();
-        final IFile editorFile = ( ( IFileEditorInput ) getEditorInput() ).getFile();
-        delta.accept( new IResourceDeltaVisitor()
+        final IFile editorFile = ((IFileEditorInput) getEditorInput()).getFile();
+        delta.accept(new IResourceDeltaVisitor()
         {
-            public boolean visit( IResourceDelta delta ) throws CoreException
+            public boolean visit(IResourceDelta delta) throws CoreException
             {
                 int kind = delta.getKind();
                 IResource resource = delta.getResource();
-                if ( resource instanceof IProject )
+                if (resource instanceof IProject)
                 {
                     int flags = delta.getFlags();
-                    return handleProjectChange(editorFile, (IProject) resource, kind, flags);
+                    return handleProjectChange(editorFile, (IProject) resource, kind,
+                        flags);
                 }
 
-                if ( resource instanceof IFile )
+                if (resource instanceof IFile)
                 {
                     handleFileChange(editorFile, (IFile) resource, kind);
                     // Recurse no more
@@ -284,158 +277,155 @@
 
                 return true;
             }
-        } );
+        });
     }
 
-
     protected void handleFileChange(IFile editorFile, IFile affectedFile, int kind)
     {
-        if ( affectedFile.equals( editorFile ) )
+        if (affectedFile.equals(editorFile))
         {
-            switch ( kind )
+            switch (kind)
             {
                 case IResourceDelta.REMOVED:
-                    close( false );
+                    close(false);
                     break;
                 case IResourceDelta.CHANGED:
-                    if ( !saving )
+                    if (!saving)
                     {
                         reload();
                     }
-                    SigilUI.runInUISync( new Runnable()
+                    SigilUI.runInUISync(new Runnable()
                     {
                         public void run()
                         {
-                            setPartName( project.getSymbolicName() );
+                            setPartName(project.getSymbolicName());
                         }
-                    } );
+                    });
                     break;
             }
         }
     }
 
-
-    private boolean handleProjectChange(IResource editorFile, IProject project, int kind, int flags) throws CoreException
+    private boolean handleProjectChange(IResource editorFile, IProject project, int kind,
+        int flags) throws CoreException
     {
-        if ( !editorFile.getProject().equals( project ) )
+        if (!editorFile.getProject().equals(project))
         {
             return false;
         }
-        if ( kind == IResourceDelta.CHANGED )
+        if (kind == IResourceDelta.CHANGED)
         {
             int mask = flags & (IResourceDelta.MARKERS);
-            if ( mask > 0 ) {
+            if (mask > 0)
+            {
                 refreshView();
             }
         }
         return true;
     }
 
-
     private void refreshView() throws CoreException
     {
         loadUnresolvedDependencies();
         refreshAllPages();
     }
 
-
     protected void refreshAllPages()
     {
         Runnable op = new Runnable()
         {
             public void run()
             {
-                for ( Iterator<?> iter = pages.iterator(); iter.hasNext(); )
+                for (Iterator<?> iter = pages.iterator(); iter.hasNext();)
                 {
-                    IFormPage page = ( IFormPage ) iter.next();
-                    if ( page != null )
+                    IFormPage page = (IFormPage) iter.next();
+                    if (page != null)
                     {
                         IManagedForm managedForm = page.getManagedForm();
-                        if ( managedForm != null )
+                        if (managedForm != null)
                         {
                             managedForm.refresh();
                             IFormPart[] parts = managedForm.getParts();
-                            for ( IFormPart part : parts )
+                            for (IFormPart part : parts)
                             {
                                 part.refresh();
                             }
                         }
                     }
                 }
-                firePropertyChange( IEditorPart.PROP_DIRTY );
-                setPartName( project.getSymbolicName() );
+                firePropertyChange(IEditorPart.PROP_DIRTY);
+                setPartName(project.getSymbolicName());
                 refreshTabImages();
             }
         };
-        getSite().getShell().getDisplay().syncExec( op );
+        getSite().getShell().getDisplay().syncExec(op);
     }
 
-
     private void reload()
     {
         tempProject.setBundle(null);
-        project.setBundle( null );
+        project.setBundle(null);
         refreshAllPages();
     }
 
-
     @Override
-    public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+    public void init(IEditorSite site, IEditorInput input) throws PartInitException
     {
-        super.init( site, input );
+        super.init(site, input);
 
         try
         {
-            this.project = SigilCore.create( getProject() );
+            this.project = SigilCore.create(getProject());
             this.tempProject = (ISigilProjectModel) project.clone();
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            throw new PartInitException( "Error creating Sigil project", e );
+            throw new PartInitException("Error creating Sigil project", e);
         }
 
-        ResourcesPlugin.getWorkspace().addResourceChangeListener( this, IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_REFRESH );
-                
-        if ( input instanceof IFileEditorInput )
+        ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
+            IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_REFRESH);
+
+        if (input instanceof IFileEditorInput)
         {
             try
             {
                 loadUnresolvedDependencies();
             }
-            catch ( CoreException e )
+            catch (CoreException e)
             {
-                throw new PartInitException( "Error retrieving dependency markers", e );
+                throw new PartInitException("Error retrieving dependency markers", e);
             }
         }
     }
 
-
     private void loadUnresolvedDependencies() throws CoreException
     {
         ModelElementFactory factory = ModelElementFactory.getInstance();
-        IMarker[] markers = getProject()
-            .findMarkers( SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true, IResource.DEPTH_ONE );
+        IMarker[] markers = getProject().findMarkers(
+            SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true, IResource.DEPTH_ONE);
         unresolvedElements.clear();
 
-        for ( IMarker marker : markers )
+        for (IMarker marker : markers)
         {
-            String elementName = ( String ) marker.getAttribute( "element" );
-            String versionRangeStr = ( String ) marker.getAttribute( "versionRange" );
-            if ( elementName != null && versionRangeStr != null )
+            String elementName = (String) marker.getAttribute("element");
+            String versionRangeStr = (String) marker.getAttribute("versionRange");
+            if (elementName != null && versionRangeStr != null)
             {
-                if ( marker.getType().equals( SigilCore.MARKER_UNRESOLVED_IMPORT_PACKAGE ) )
+                if (marker.getType().equals(SigilCore.MARKER_UNRESOLVED_IMPORT_PACKAGE))
                 {
-                    IPackageImport pkgImport = factory.newModelElement( IPackageImport.class );
-                    pkgImport.setPackageName( elementName );
-                    pkgImport.setVersions( VersionRange.parseVersionRange( versionRangeStr ) );
-                    unresolvedElements.add( pkgImport );
+                    IPackageImport pkgImport = factory.newModelElement(IPackageImport.class);
+                    pkgImport.setPackageName(elementName);
+                    pkgImport.setVersions(VersionRange.parseVersionRange(versionRangeStr));
+                    unresolvedElements.add(pkgImport);
                 }
-                else if ( marker.getType().equals( SigilCore.MARKER_UNRESOLVED_REQUIRE_BUNDLE ) )
+                else if (marker.getType().equals(
+                    SigilCore.MARKER_UNRESOLVED_REQUIRE_BUNDLE))
                 {
-                    IRequiredBundle req = factory.newModelElement( IRequiredBundle.class );
-                    req.setSymbolicName( elementName );
-                    req.setVersions( VersionRange.parseVersionRange( versionRangeStr ) );
-                    unresolvedElements.add( req );
+                    IRequiredBundle req = factory.newModelElement(IRequiredBundle.class);
+                    req.setSymbolicName(elementName);
+                    req.setVersions(VersionRange.parseVersionRange(versionRangeStr));
+                    unresolvedElements.add(req);
                 }
             }
         }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilSourcePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilSourcePage.java
index 064ca41..1b38972 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilSourcePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilSourcePage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.jface.text.ITextListener;
 import org.eclipse.jface.text.TextEvent;
@@ -31,7 +30,6 @@
 import org.eclipse.ui.forms.editor.IFormPage;
 import org.eclipse.ui.ide.IDE;
 
-
 public class SigilSourcePage extends TextEditor implements IFormPage
 {
     private final String id;
@@ -40,105 +38,91 @@
     private boolean active;
     private Control control;
 
-
-    public SigilSourcePage( String id )
+    public SigilSourcePage(String id)
     {
         this.id = id;
     }
 
-
     @Override
-    public void createPartControl( Composite parent )
+    public void createPartControl(Composite parent)
     {
-        super.createPartControl( parent );
+        super.createPartControl(parent);
         Control[] children = parent.getChildren();
         control = children[children.length - 1];
-        getSourceViewer().addTextListener( new ITextListener()
+        getSourceViewer().addTextListener(new ITextListener()
         {
-            public void textChanged( TextEvent event )
+            public void textChanged(TextEvent event)
             {
-                if ( editor != null )
+                if (editor != null)
                 {
                     editor.refreshAllPages();
                 }
             }
-        } );
+        });
         //PlatformUI.getWorkbench().getHelpSystem().setHelp(fControl, IHelpContextIds.MANIFEST_SOURCE_PAGE);
     }
 
-
-    public void initialize( FormEditor editor )
+    public void initialize(FormEditor editor)
     {
-        this.editor = ( SigilProjectEditorPart ) editor;
+        this.editor = (SigilProjectEditorPart) editor;
     }
 
-
     public FormEditor getEditor()
     {
         return editor;
     }
 
-
     public String getId()
     {
         return id;
     }
 
-
     public int getIndex()
     {
         return index;
     }
 
-
-    public void setIndex( int index )
+    public void setIndex(int index)
     {
         this.index = index;
     }
 
-
     public boolean isActive()
     {
         return active;
     }
 
-
-    public void setActive( boolean active )
+    public void setActive(boolean active)
     {
         this.active = active;
     }
 
-
     public Control getPartControl()
     {
         return control;
     }
 
-
-    public boolean selectReveal( Object object )
+    public boolean selectReveal(Object object)
     {
-        if ( object instanceof IMarker )
+        if (object instanceof IMarker)
         {
-            IDE.gotoMarker( this, ( IMarker ) object );
+            IDE.gotoMarker(this, (IMarker) object);
             return true;
         }
         return false;
     }
 
-
     // static impls
     public boolean isEditor()
     {
         return true;
     }
 
-
     public boolean canLeaveThePage()
     {
         return true;
     }
 
-
     public IManagedForm getManagedForm()
     {
         // this is not a form
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/TestingSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/TestingSection.java
index 4ac1185..24b2e1f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/TestingSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/TestingSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
 import org.apache.felix.sigil.eclipse.ui.internal.form.SigilSection;
@@ -36,60 +35,59 @@
 import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.Section;
 
-
 public class TestingSection extends SigilSection
 {
 
-    public TestingSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public TestingSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
-    protected void createSection( Section section, FormToolkit toolkit )
+    protected void createSection(Section section, FormToolkit toolkit)
     {
-        setTitle( "Testing" );
+        setTitle("Testing");
 
-        Composite body = createTableWrapBody( 1, toolkit );
+        Composite body = createTableWrapBody(1, toolkit);
 
-        toolkit.createLabel( body, "Test this project by launching a separate Newton application:" );
+        toolkit.createLabel(body,
+            "Test this project by launching a separate Newton application:");
 
-        Hyperlink launch = toolkit.createHyperlink( body, "Launch a newton container", SWT.NULL );
-        launch.setHref( "launchShortcut.run.org.cauldron.sigil.launching.shortcut" );
-        launch.addHyperlinkListener( this );
+        Hyperlink launch = toolkit.createHyperlink(body, "Launch a newton container",
+            SWT.NULL);
+        launch.setHref("launchShortcut.run.org.cauldron.sigil.launching.shortcut");
+        launch.addHyperlinkListener(this);
 
-        Hyperlink debug = toolkit.createHyperlink( body, "Debug a newton container", SWT.NULL );
-        debug.setHref( "launchShortcut.debug.org.cauldron.sigil.launching.shortcut" );
-        debug.addHyperlinkListener( this );
+        Hyperlink debug = toolkit.createHyperlink(body, "Debug a newton container",
+            SWT.NULL);
+        debug.setHref("launchShortcut.debug.org.cauldron.sigil.launching.shortcut");
+        debug.addHyperlinkListener(this);
     }
 
-
-    public void linkActivated( HyperlinkEvent e )
+    public void linkActivated(HyperlinkEvent e)
     {
-        String href = ( String ) e.getHref();
-        if ( href.startsWith( "launchShortcut." ) ) { //$NON-NLS-1$
-            href = href.substring( 15 );
-            int index = href.indexOf( '.' );
-            if ( index < 0 )
+        String href = (String) e.getHref();
+        if (href.startsWith("launchShortcut.")) { //$NON-NLS-1$
+            href = href.substring(15);
+            int index = href.indexOf('.');
+            if (index < 0)
                 return; // error.  Format of href should be launchShortcut.<mode>.<launchShortcutId>
-            String mode = href.substring( 0, index );
-            String id = href.substring( index + 1 );
+            String mode = href.substring(0, index);
+            String id = href.substring(index + 1);
 
             //getEditor().doSave(null);
 
             IExtensionRegistry registry = Platform.getExtensionRegistry();
-            IConfigurationElement[] elements = registry
-                .getConfigurationElementsFor( "org.eclipse.debug.ui.launchShortcuts" ); //$NON-NLS-1$
-            for ( int i = 0; i < elements.length; i++ )
+            IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.debug.ui.launchShortcuts"); //$NON-NLS-1$
+            for (int i = 0; i < elements.length; i++)
             {
-                if ( id.equals( elements[i].getAttribute( "id" ) ) ) //$NON-NLS-1$
+                if (id.equals(elements[i].getAttribute("id"))) //$NON-NLS-1$
                     try
                     {
-                        ILaunchShortcut shortcut = ( ILaunchShortcut ) elements[i].createExecutableExtension( "class" ); //$NON-NLS-1$
+                        ILaunchShortcut shortcut = (ILaunchShortcut) elements[i].createExecutableExtension("class"); //$NON-NLS-1$
                         // preLaunch();
-                        shortcut.launch( new StructuredSelection( getLaunchObject() ), mode );
+                        shortcut.launch(new StructuredSelection(getLaunchObject()), mode);
                     }
-                    catch ( CoreException e1 )
+                    catch (CoreException e1)
                     {
                         e1.printStackTrace();
                     }
@@ -97,19 +95,16 @@
         }
     }
 
-
     private Object getLaunchObject()
     {
         return getProjectModel().getProject();
     }
 
-
-    public void linkEntered( HyperlinkEvent e )
+    public void linkEntered(HyperlinkEvent e)
     {
     }
 
-
-    public void linkExited( HyperlinkEvent e )
+    public void linkExited(HyperlinkEvent e)
     {
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ToolsSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ToolsSection.java
index 050388e..f8a5b57 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ToolsSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ToolsSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.eclipse.ui.actions.PruneProjectDependenciesAction;
 import org.apache.felix.sigil.eclipse.ui.actions.ResolveProjectDependenciesAction;
@@ -33,67 +32,62 @@
 import org.eclipse.ui.forms.widgets.Hyperlink;
 import org.eclipse.ui.forms.widgets.Section;
 
-
 public class ToolsSection extends SigilSection
 {
 
-    public ToolsSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public ToolsSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( page, parent, project );
+        super(page, parent, project);
     }
 
-
-    protected void createSection( Section section, FormToolkit toolkit )
+    protected void createSection(Section section, FormToolkit toolkit)
     {
-        setTitle( "Tools" );
+        setTitle("Tools");
 
-        Composite body = createTableWrapBody( 1, toolkit );
+        Composite body = createTableWrapBody(1, toolkit);
 
-        toolkit.createLabel( body, "Tools to help manage this project:" );
+        toolkit.createLabel(body, "Tools to help manage this project:");
 
-        Hyperlink launch = toolkit.createHyperlink( body, "Resolve missing dependencies", SWT.NULL );
-        launch.setHref( "resolve" );
-        launch.addHyperlinkListener( this );
+        Hyperlink launch = toolkit.createHyperlink(body, "Resolve missing dependencies",
+            SWT.NULL);
+        launch.setHref("resolve");
+        launch.addHyperlinkListener(this);
 
-        Hyperlink debug = toolkit.createHyperlink( body, "Prune unused dependencies", SWT.NULL );
-        debug.setHref( "prune" );
-        debug.addHyperlinkListener( this );
+        Hyperlink debug = toolkit.createHyperlink(body, "Prune unused dependencies",
+            SWT.NULL);
+        debug.setHref("prune");
+        debug.addHyperlinkListener(this);
     }
 
-
-    public void linkActivated( HyperlinkEvent e )
+    public void linkActivated(HyperlinkEvent e)
     {
-        String href = ( String ) e.getHref();
-        if ( "resolve".equals( href ) )
+        String href = (String) e.getHref();
+        if ("resolve".equals(href))
         {
             handleResolve();
         }
-        else if ( "prune".equals( href ) )
+        else if ("prune".equals(href))
         {
             handlePrune();
         }
     }
 
-
     private void handlePrune()
     {
-        new PruneProjectDependenciesAction( getProjectModel() ).run();
+        new PruneProjectDependenciesAction(getProjectModel()).run();
     }
 
-
     private void handleResolve()
     {
         final ISigilProjectModel project = getProjectModel();
-        new ResolveProjectDependenciesAction( project, true ).run();
+        new ResolveProjectDependenciesAction(project, true).run();
     }
 
-
-    public void linkEntered( HyperlinkEvent e )
+    public void linkEntered(HyperlinkEvent e)
     {
     }
 
-
-    public void linkExited( HyperlinkEvent e )
+    public void linkExited(HyperlinkEvent e)
     {
     }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionRangeComponent.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionRangeComponent.java
index 5feb668..db97af2 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionRangeComponent.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionRangeComponent.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
 
-
 import java.util.HashSet;
 import java.util.Set;
 
@@ -40,7 +39,6 @@
 import org.eclipse.swt.widgets.Text;
 import org.osgi.framework.Version;
 
-
 public class VersionRangeComponent extends Composite
 {
     private VersionRange versions = VersionRange.ANY_VERSION;
@@ -57,257 +55,244 @@
     private Set<VersionsChangeListener> listeners = new HashSet<VersionsChangeListener>();
     private Set<IValidationListener> validationListeners = new HashSet<IValidationListener>();
 
-
-    public VersionRangeComponent( Composite parent, int style )
+    public VersionRangeComponent(Composite parent, int style)
     {
-        super( parent, style );
-        createComponents( this );
+        super(parent, style);
+        createComponents(this);
     }
 
-
-    public void addVersionChangeListener( VersionsChangeListener listener )
+    public void addVersionChangeListener(VersionsChangeListener listener)
     {
-        synchronized ( listeners )
+        synchronized (listeners)
         {
-            listeners.add( listener );
+            listeners.add(listener);
         }
     }
 
-
-    public void removeVersionChangeListener( VersionsChangeListener listener )
+    public void removeVersionChangeListener(VersionsChangeListener listener)
     {
-        synchronized ( listeners )
+        synchronized (listeners)
         {
-            listeners.remove( listener );
+            listeners.remove(listener);
         }
     }
 
-
-    public void addValidationListener( IValidationListener listener )
+    public void addValidationListener(IValidationListener listener)
     {
-        validationListeners.add( listener );
+        validationListeners.add(listener);
     }
 
-
-    public void removeValidationListener( IValidationListener listener )
+    public void removeValidationListener(IValidationListener listener)
     {
-        validationListeners.remove( listener );
+        validationListeners.remove(listener);
     }
 
-
     @Override
-    public void setEnabled( boolean enabled )
+    public void setEnabled(boolean enabled)
     {
-        super.setEnabled( enabled );
-        specificButton.setEnabled( enabled );
-        rangeButton.setEnabled( enabled );
-        if ( enabled )
+        super.setEnabled(enabled);
+        specificButton.setEnabled(enabled);
+        rangeButton.setEnabled(enabled);
+        if (enabled)
         {
-            specificButton.setSelection( versions.isPointVersion() );
+            specificButton.setSelection(versions.isPointVersion());
             setSpecific();
         }
         else
         {
-            minimumText.setEnabled( enabled );
-            maximumText.setEnabled( enabled );
-            minInclusiveButton.setEnabled( enabled );
-            maxInclusiveButton.setEnabled( enabled );
+            minimumText.setEnabled(enabled);
+            maximumText.setEnabled(enabled);
+            minInclusiveButton.setEnabled(enabled);
+            maxInclusiveButton.setEnabled(enabled);
         }
     }
 
-
     public VersionRange getVersions()
     {
         return versions;
     }
 
-
-    public void setVersions( VersionRange versions )
+    public void setVersions(VersionRange versions)
     {
         this.versions = versions == null ? VersionRange.ANY_VERSION : versions;
         updateFields();
     }
 
-
     private void updateFields()
     {
-        if ( versions.isPointVersion() )
+        if (versions.isPointVersion())
         {
-            specificButton.setSelection( true );
-            specificText.setText( versions.getCeiling() == VersionRange.INFINITE_VERSION ? "*" : versions.getFloor()
-                .toString() );
+            specificButton.setSelection(true);
+            specificText.setText(versions.getCeiling() == VersionRange.INFINITE_VERSION ? "*"
+                : versions.getFloor().toString());
         }
         else
         {
-            rangeButton.setSelection( true );
-            minimumText.setText( versions.getFloor().toString() );
-            minInclusiveButton.setSelection( !versions.isOpenFloor() );
-            maximumText.setText( versions.getCeiling() == VersionRange.INFINITE_VERSION ? "*" : versions.getCeiling()
-                .toString() );
-            maxInclusiveButton.setSelection( !versions.isOpenCeiling() );
+            rangeButton.setSelection(true);
+            minimumText.setText(versions.getFloor().toString());
+            minInclusiveButton.setSelection(!versions.isOpenFloor());
+            maximumText.setText(versions.getCeiling() == VersionRange.INFINITE_VERSION ? "*"
+                : versions.getCeiling().toString());
+            maxInclusiveButton.setSelection(!versions.isOpenCeiling());
         }
 
         setSpecific();
     }
 
-
-    private void createComponents( Composite body )
+    private void createComponents(Composite body)
     {
-        setLayout( new GridLayout( 3, false ) );
+        setLayout(new GridLayout(3, false));
 
-        specificButton = new Button( body, SWT.RADIO );
-        specificButton.setText( "Specific:" );
-        specificButton.addSelectionListener( new SelectionAdapter()
+        specificButton = new Button(body, SWT.RADIO);
+        specificButton.setText("Specific:");
+        specificButton.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 setSpecific();
             }
-        } );
+        });
 
-        new Label( body, SWT.NONE ).setText( "Version:" );
+        new Label(body, SWT.NONE).setText("Version:");
 
-        specificText = new Text( body, SWT.BORDER );
-        specificText.addKeyListener( new KeyAdapter()
+        specificText = new Text(body, SWT.BORDER);
+        specificText.addKeyListener(new KeyAdapter()
         {
             @Override
-            public void keyReleased( KeyEvent e )
+            public void keyReleased(KeyEvent e)
             {
                 setVersions();
             }
-        } );
+        });
 
-        rangeButton = new Button( body, SWT.RADIO );
-        rangeButton.setText( "Range:" );
+        rangeButton = new Button(body, SWT.RADIO);
+        rangeButton.setText("Range:");
 
-        new Label( body, SWT.NONE ).setText( "Minimum:" );
+        new Label(body, SWT.NONE).setText("Minimum:");
 
-        minimumText = new Text( body, SWT.BORDER );
-        minimumText.addKeyListener( new KeyAdapter()
+        minimumText = new Text(body, SWT.BORDER);
+        minimumText.addKeyListener(new KeyAdapter()
         {
             @Override
-            public void keyReleased( KeyEvent e )
+            public void keyReleased(KeyEvent e)
             {
                 setVersions();
             }
-        } );
+        });
 
-        minInclusiveButton = new Button( body, SWT.CHECK );
-        minInclusiveButton.setText( "inclusive" );
-        minInclusiveButton.setSelection( true );
-        minInclusiveButton.addSelectionListener( new SelectionAdapter()
+        minInclusiveButton = new Button(body, SWT.CHECK);
+        minInclusiveButton.setText("inclusive");
+        minInclusiveButton.setSelection(true);
+        minInclusiveButton.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 setVersions();
             }
-        } );
+        });
 
-        new Label( body, SWT.NONE ).setText( "Maximum:" );
-        maximumText = new Text( body, SWT.BORDER );
-        maximumText.addKeyListener( new KeyAdapter()
+        new Label(body, SWT.NONE).setText("Maximum:");
+        maximumText = new Text(body, SWT.BORDER);
+        maximumText.addKeyListener(new KeyAdapter()
         {
             @Override
-            public void keyReleased( KeyEvent e )
+            public void keyReleased(KeyEvent e)
             {
                 setVersions();
             }
-        } );
+        });
 
-        maxInclusiveButton = new Button( body, SWT.CHECK );
-        maxInclusiveButton.setText( "inclusive" );
-        maxInclusiveButton.setSelection( false );
-        maxInclusiveButton.addSelectionListener( new SelectionAdapter()
+        maxInclusiveButton = new Button(body, SWT.CHECK);
+        maxInclusiveButton.setText("inclusive");
+        maxInclusiveButton.setSelection(false);
+        maxInclusiveButton.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 setVersions();
             }
-        } );
+        });
 
         // Layout
-        specificButton.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 3, 1 ) );
-        specificText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 2, 1 ) );
-        rangeButton.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 3, 1 ) );
-        minimumText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        maximumText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+        specificButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
+        specificText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+        rangeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
+        minimumText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        maximumText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
 
         updateFields();
     }
 
-
     private void setVersions()
     {
         try
         {
-            if ( specificButton.getSelection() )
+            if (specificButton.getSelection())
             {
-                if ( "*".equals( specificText.getText() ) )
+                if ("*".equals(specificText.getText()))
                 {
                     versions = VersionRange.ANY_VERSION;
                 }
-                else if ( specificText.getText().trim().length() == 0 )
+                else if (specificText.getText().trim().length() == 0)
                 {
                     versions = null;
                 }
                 else
                 {
-                    Version v = VersionTable.getVersion( specificText.getText().trim() );
-                    versions = new VersionRange( false, v, v, false );
+                    Version v = VersionTable.getVersion(specificText.getText().trim());
+                    versions = new VersionRange(false, v, v, false);
                 }
             }
             else
             {
-                Version min = VersionTable.getVersion( minimumText.getText() );
-                Version max = "*".equals( maximumText.getText() ) ? VersionRange.INFINITE_VERSION : VersionTable.getVersion( maximumText.getText() );
-                versions = new VersionRange( !minInclusiveButton.getSelection(), min, max, !maxInclusiveButton
-                    .getSelection() );
+                Version min = VersionTable.getVersion(minimumText.getText());
+                Version max = "*".equals(maximumText.getText()) ? VersionRange.INFINITE_VERSION
+                    : VersionTable.getVersion(maximumText.getText());
+                versions = new VersionRange(!minInclusiveButton.getSelection(), min, max,
+                    !maxInclusiveButton.getSelection());
             }
-            fireValidationMessage( null, IMessageProvider.NONE );
+            fireValidationMessage(null, IMessageProvider.NONE);
         }
-        catch ( IllegalArgumentException e )
+        catch (IllegalArgumentException e)
         {
             versions = null;
-            fireValidationMessage( "Invalid version", IMessageProvider.ERROR );
+            fireValidationMessage("Invalid version", IMessageProvider.ERROR);
         }
 
         fireVersionChange();
     }
 
-
     private void fireVersionChange()
     {
-        synchronized ( listeners )
+        synchronized (listeners)
         {
-            for ( VersionsChangeListener l : listeners )
+            for (VersionsChangeListener l : listeners)
             {
-                l.versionsChanged( versions );
+                l.versionsChanged(versions);
             }
         }
     }
 
-
-    private void fireValidationMessage( String message, int level )
+    private void fireValidationMessage(String message, int level)
     {
-        for ( IValidationListener validationListener : validationListeners )
+        for (IValidationListener validationListener : validationListeners)
         {
-            validationListener.validationMessage( message, level );
+            validationListener.validationMessage(message, level);
         }
     }
 
-
     private void setSpecific()
     {
         boolean specific = specificButton.getSelection();
-        specificButton.setSelection( specific );
-        specificText.setEnabled( specific );
-        minimumText.setEnabled( !specific );
-        maximumText.setEnabled( !specific );
-        minInclusiveButton.setEnabled( !specific );
-        maxInclusiveButton.setEnabled( !specific );
+        specificButton.setSelection(specific);
+        specificText.setEnabled(specific);
+        minimumText.setEnabled(!specific);
+        maximumText.setEnabled(!specific);
+        minInclusiveButton.setEnabled(!specific);
+        maxInclusiveButton.setEnabled(!specific);
         setVersions();
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionsChangeListener.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionsChangeListener.java
index 373336c..c8c2c09 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionsChangeListener.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionsChangeListener.java
@@ -23,5 +23,5 @@
 
 public interface VersionsChangeListener
 {
-    void versionsChanged( VersionRange range );
+    void versionsChanged(VersionRange range);
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/IFormValueConverter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/IFormValueConverter.java
index aefd69b..8897857 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/IFormValueConverter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/IFormValueConverter.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.form;
 
-
 public interface IFormValueConverter
 {
-    String getLabel( Object value );
+    String getLabel(Object value);
 
-
-    Object getValue( String label );
+    Object getValue(String label);
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/ISigilFormEntryListener.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/ISigilFormEntryListener.java
index 5ed9a3e..9c09f27 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/ISigilFormEntryListener.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/ISigilFormEntryListener.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.form;
 
-
 public interface ISigilFormEntryListener
 {
-    void browseButtonSelected( SigilFormEntry form );
+    void browseButtonSelected(SigilFormEntry form);
 
-
-    void textValueChanged( SigilFormEntry form );
+    void textValueChanged(SigilFormEntry form);
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntry.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntry.java
index 39ba2be..db480fa 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntry.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntry.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.form;
 
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.FocusAdapter;
 import org.eclipse.swt.events.FocusEvent;
@@ -36,18 +35,16 @@
 import org.eclipse.ui.forms.IFormColors;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
-
 public class SigilFormEntry
 {
     private static final IFormValueConverter NULL_DESCRIPTOR = new IFormValueConverter()
     {
-        public String getLabel( Object value )
+        public String getLabel(Object value)
         {
-            return ( String ) value;
+            return (String) value;
         }
 
-
-        public Object getValue( String label )
+        public Object getValue(String label)
         {
             return label;
         }
@@ -62,77 +59,69 @@
     private Object value;
     private ISigilFormEntryListener listener;
 
-
-    public SigilFormEntry( Composite parent, FormToolkit toolkit, String title )
+    public SigilFormEntry(Composite parent, FormToolkit toolkit, String title)
     {
-        this( parent, toolkit, title, null, null );
+        this(parent, toolkit, title, null, null);
     }
 
-
-    public SigilFormEntry( Composite parent, FormToolkit toolkit, String title, String browse,
-        IFormValueConverter descriptor )
+    public SigilFormEntry(Composite parent, FormToolkit toolkit, String title, String browse, IFormValueConverter descriptor)
     {
         this.descriptor = descriptor == null ? NULL_DESCRIPTOR : descriptor;
-        createComponent( parent, title, browse, toolkit );
+        createComponent(parent, title, browse, toolkit);
     }
 
-
-    public void setFormEntryListener( ISigilFormEntryListener listener )
+    public void setFormEntryListener(ISigilFormEntryListener listener)
     {
         this.listener = listener;
     }
 
-
-    public void setValue( Object value )
+    public void setValue(Object value)
     {
         this.value = value;
-        String text = descriptor.getLabel( value );
-        if ( text == null )
+        String text = descriptor.getLabel(value);
+        if (text == null)
         {
             text = "";
         }
-        txt.setText( text );
+        txt.setText(text);
         handleValueChanged();
     }
 
-
     public Object getValue()
     {
         return value;
     }
 
-
-    public void setFreeText( boolean freeText )
+    public void setFreeText(boolean freeText)
     {
         this.freeText = freeText;
     }
 
-
-    public void setEditable( boolean editable )
+    public void setEditable(boolean editable)
     {
-        lbl.setEnabled( editable );
-        txt.setEditable( editable );
-        if ( btn != null )
+        lbl.setEnabled(editable);
+        txt.setEditable(editable);
+        if (btn != null)
         {
-            btn.setEnabled( editable );
+            btn.setEnabled(editable);
         }
     }
 
-
-    private void createComponent( Composite parent, String title, String browse, FormToolkit toolkit )
+    private void createComponent(Composite parent, String title, String browse,
+        FormToolkit toolkit)
     {
-        lbl = toolkit.createLabel( parent, title );
-        lbl.setForeground( toolkit.getColors().getColor( IFormColors.TITLE ) );
+        lbl = toolkit.createLabel(parent, title);
+        lbl.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
 
-        txt = toolkit.createText( parent, "", SWT.SINGLE | SWT.BORDER );
-        txt.addKeyListener( new KeyAdapter()
+        txt = toolkit.createText(parent, "", SWT.SINGLE | SWT.BORDER);
+        txt.addKeyListener(new KeyAdapter()
         {
             @Override
-            public void keyPressed( KeyEvent e )
+            public void keyPressed(KeyEvent e)
             {
-                if ( freeText )
+                if (freeText)
                 {
-                    switch ( e.character )
+                    switch (e.character)
                     {
                         case '\r':
                             handleValueChanged();
@@ -140,10 +129,10 @@
                 }
                 else
                 {
-                    switch ( e.character )
+                    switch (e.character)
                     {
                         case '\b':
-                            setValue( null );
+                            setValue(null);
                             handleValueChanged();
                         default:
                             e.doit = false;
@@ -151,72 +140,71 @@
                     }
                 }
             }
-        } );
-        txt.addFocusListener( new FocusAdapter()
+        });
+        txt.addFocusListener(new FocusAdapter()
         {
             @Override
-            public void focusLost( FocusEvent e )
+            public void focusLost(FocusEvent e)
             {
                 handleValueChanged();
             }
-        } );
+        });
 
-        if ( browse != null )
+        if (browse != null)
         {
-            btn = toolkit.createButton( parent, browse, SWT.PUSH );
-            btn.addSelectionListener( new SelectionAdapter()
+            btn = toolkit.createButton(parent, browse, SWT.PUSH);
+            btn.addSelectionListener(new SelectionAdapter()
             {
                 @Override
-                public void widgetSelected( SelectionEvent e )
+                public void widgetSelected(SelectionEvent e)
                 {
                     handleBrowseSelected();
                 }
-            } );
+            });
         }
 
-        fillIntoGrid( parent );
+        fillIntoGrid(parent);
     }
 
-
     private void handleBrowseSelected()
     {
-        if ( listener != null )
+        if (listener != null)
         {
-            listener.browseButtonSelected( this );
+            listener.browseButtonSelected(this);
         }
     }
 
-
     private void handleValueChanged()
     {
-        if ( freeText )
+        if (freeText)
         {
-            this.value = descriptor.getValue( txt.getText() );
+            this.value = descriptor.getValue(txt.getText());
         }
-        if ( listener != null )
+        if (listener != null)
         {
-            listener.textValueChanged( this );
+            listener.textValueChanged(this);
         }
     }
 
-
-    private void fillIntoGrid( Composite parent )
+    private void fillIntoGrid(Composite parent)
     {
-        if ( parent.getLayout() instanceof GridLayout )
+        if (parent.getLayout() instanceof GridLayout)
         {
-            GridLayout layout = ( GridLayout ) parent.getLayout();
+            GridLayout layout = (GridLayout) parent.getLayout();
 
             int cols = layout.numColumns;
 
-            lbl.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false ) );
+            lbl.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
 
-            if ( btn == null )
+            if (btn == null)
             {
-                txt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, Math.max( 1, cols - 1 ), 1 ) );
+                txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
+                    Math.max(1, cols - 1), 1));
             }
             else
             {
-                txt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, Math.max( 1, cols - 2 ), 1 ) );
+                txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
+                    Math.max(1, cols - 2), 1));
             }
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntryAdapter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntryAdapter.java
index e96237f..df25a5e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntryAdapter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntryAdapter.java
@@ -19,15 +19,13 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.form;
 
-
 public class SigilFormEntryAdapter implements ISigilFormEntryListener
 {
-    public void browseButtonSelected( SigilFormEntry form )
+    public void browseButtonSelected(SigilFormEntry form)
     {
     }
 
-
-    public void textValueChanged( SigilFormEntry form )
+    public void textValueChanged(SigilFormEntry form)
     {
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilPage.java
index 20c976f..12be8b8 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilPage.java
@@ -19,17 +19,15 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.form;
 
-
 import org.eclipse.ui.forms.editor.FormEditor;
 import org.eclipse.ui.forms.editor.FormPage;
 
-
 public class SigilPage extends FormPage
 {
 
-    public SigilPage( FormEditor editor, String id, String title )
+    public SigilPage(FormEditor editor, String id, String title)
     {
-        super( editor, id, title );
+        super(editor, id, title);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilSection.java
index e95e941..37245bf 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilSection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.form;
 
-
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
@@ -40,7 +39,6 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
-
 @SuppressWarnings("restriction")
 public abstract class SigilSection extends SectionPart implements IHyperlinkListener, IPartSelectionListener
 {
@@ -48,127 +46,122 @@
     private SigilPage page;
     private ISigilProjectModel project;
 
-
-    public SigilSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    public SigilSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
     {
-        super( parent, page.getManagedForm().getToolkit(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE
-            | ExpandableComposite.EXPANDED );
+        super(parent, page.getManagedForm().getToolkit(), ExpandableComposite.TITLE_BAR
+            | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         this.project = project;
         this.page = page;
-        createSection( getSection(), page.getManagedForm().getToolkit() );
+        createSection(getSection(), page.getManagedForm().getToolkit());
     }
 
-
     public ISigilProjectModel getProjectModel()
     {
         return project;
     }
 
-
     public SigilPage getPage()
     {
         return page;
     }
 
-
-    public void setExpanded( boolean expanded )
+    public void setExpanded(boolean expanded)
     {
-        getSection().setExpanded( expanded );
+        getSection().setExpanded(expanded);
     }
 
+    protected abstract void createSection(Section section, FormToolkit toolkit)
+        throws CoreException;
 
-    protected abstract void createSection( Section section, FormToolkit toolkit ) throws CoreException;
-
-
-    protected void setTitle( String title )
+    protected void setTitle(String title)
     {
         Section section = getSection();
-        section.setText( title );
-        
-		TableWrapLayout layout = new TableWrapLayout();
+        section.setText(title);
 
-		layout.topMargin = 2;
-		layout.bottomMargin = 2;
-		layout.leftMargin = 2;
-		layout.rightMargin = 2;
+        TableWrapLayout layout = new TableWrapLayout();
 
-		layout.horizontalSpacing = 0;
-		layout.verticalSpacing = 0;
+        layout.topMargin = 2;
+        layout.bottomMargin = 2;
+        layout.leftMargin = 2;
+        layout.rightMargin = 2;
 
-		layout.makeColumnsEqualWidth = false;
-		layout.numColumns = 1;
+        layout.horizontalSpacing = 0;
+        layout.verticalSpacing = 0;
 
-        section.setLayout( layout );
-        
-        TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB );
-        section.setLayoutData( data );
+        layout.makeColumnsEqualWidth = false;
+        layout.numColumns = 1;
+
+        section.setLayout(layout);
+
+        TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
+        section.setLayoutData(data);
     }
 
-	protected void setMarker( String type, String message, int priority, int severity ) throws CoreException
+    protected void setMarker(String type, String message, int priority, int severity)
+        throws CoreException
     {
-        IFileEditorInput file = ( IFileEditorInput ) getPage().getEditor().getEditorInput();
-        IMarker marker = file.getFile().createMarker( type );
-        marker.setAttribute( IMarker.MESSAGE, message );
-        marker.setAttribute( IMarker.PRIORITY, priority );
-        marker.setAttribute( IMarker.SEVERITY, severity );
+        IFileEditorInput file = (IFileEditorInput) getPage().getEditor().getEditorInput();
+        IMarker marker = file.getFile().createMarker(type);
+        marker.setAttribute(IMarker.MESSAGE, message);
+        marker.setAttribute(IMarker.PRIORITY, priority);
+        marker.setAttribute(IMarker.SEVERITY, severity);
     }
 
-
     protected void clearMarkers() throws CoreException
     {
-        IFileEditorInput file = ( IFileEditorInput ) getPage().getEditor().getEditorInput();
-        file.getFile().deleteMarkers( null, true, IResource.DEPTH_INFINITE );
+        IFileEditorInput file = (IFileEditorInput) getPage().getEditor().getEditorInput();
+        file.getFile().deleteMarkers(null, true, IResource.DEPTH_INFINITE);
     }
 
-
-    protected Composite createTableWrapBody( int columns, FormToolkit toolkit )
+    protected Composite createTableWrapBody(int columns, FormToolkit toolkit)
     {
         Section section = getSection();
-        Composite client = toolkit.createComposite( section );
+        Composite client = toolkit.createComposite(section);
 
         TableWrapLayout layout = new TableWrapLayout();
-        layout.leftMargin = layout.rightMargin = toolkit.getBorderStyle() != SWT.NULL ? 0 : 2;
+        layout.leftMargin = layout.rightMargin = toolkit.getBorderStyle() != SWT.NULL ? 0
+            : 2;
         layout.numColumns = columns;
-        client.setLayout( layout );
-        client.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+        client.setLayout(layout);
+        client.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
 
-        section.setClient( client );
+        section.setClient(client);
 
         return client;
     }
 
-
-    protected Composite createGridBody( int columns, boolean columnsSameWidth, FormToolkit toolkit )
+    protected Composite createGridBody(int columns, boolean columnsSameWidth,
+        FormToolkit toolkit)
     {
         Section section = getSection();
-        Composite client = toolkit.createComposite( section );
+        Composite client = toolkit.createComposite(section);
 
         GridLayout layout = new GridLayout();
 
         layout.makeColumnsEqualWidth = columnsSameWidth;
         layout.numColumns = columns;
-        client.setLayout( layout );
+        client.setLayout(layout);
 
-        client.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+        client.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
 
-        section.setClient( client );
+        section.setClient(client);
 
         return client;
     }
 
-    public void linkActivated( HyperlinkEvent e )
-    {        
+    public void linkActivated(HyperlinkEvent e)
+    {
     }
-    
+
     public void linkExited(HyperlinkEvent e)
-    {	
+    {
     }
-    
+
     public void linkEntered(HyperlinkEvent e)
     {
     }
 
-    public void selectionChanged( IFormPart part, ISelection selection )
+    public void selectionChanged(IFormPart part, ISelection selection)
     {
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/AbstractResourceCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/AbstractResourceCommandHandler.java
index f365026..6f77d31 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/AbstractResourceCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/AbstractResourceCommandHandler.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.handlers;
 
-
 import org.eclipse.core.commands.AbstractHandler;
 
-
 public abstract class AbstractResourceCommandHandler extends AbstractHandler
 {
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/EditorResourceCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/EditorResourceCommandHandler.java
index 8a444aa..addde2b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/EditorResourceCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/EditorResourceCommandHandler.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.handlers;
 
-
 import java.lang.reflect.InvocationTargetException;
 
 import org.eclipse.core.commands.ExecutionEvent;
@@ -36,38 +35,39 @@
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.handlers.HandlerUtil;
 
-
 public abstract class EditorResourceCommandHandler extends AbstractResourceCommandHandler
 {
 
-    public Object execute( ExecutionEvent event ) throws ExecutionException
+    public Object execute(ExecutionEvent event) throws ExecutionException
     {
-        final Shell shell = HandlerUtil.getActiveShell( event );
-        final IEditorPart editorPart = HandlerUtil.getActiveEditor( event );
-        if ( editorPart != null )
+        final Shell shell = HandlerUtil.getActiveShell(event);
+        final IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
+        if (editorPart != null)
         {
             IEditorInput editorInput = editorPart.getEditorInput();
 
-            if ( !( editorInput instanceof IFileEditorInput ) )
+            if (!(editorInput instanceof IFileEditorInput))
             {
-                throw new ExecutionException( "Editor input must be a file" );
+                throw new ExecutionException("Editor input must be a file");
             }
-            IFileEditorInput fileInput = ( IFileEditorInput ) editorInput;
+            IFileEditorInput fileInput = (IFileEditorInput) editorInput;
 
             try
             {
                 // Save the editor content (if dirty)
                 IRunnableWithProgress saveOperation = new IRunnableWithProgress()
                 {
-                    public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException
+                    public void run(IProgressMonitor monitor)
+                        throws InvocationTargetException, InterruptedException
                     {
-                        if ( editorPart.isDirty() )
+                        if (editorPart.isDirty())
                         {
-                            if ( MessageDialog
-                                .openQuestion( shell, "Save File",
-                                    "The file contents must be saved before the command can be executed. Do you wish to save now?" ) )
+                            if (MessageDialog.openQuestion(
+                                shell,
+                                "Save File",
+                                "The file contents must be saved before the command can be executed. Do you wish to save now?"))
                             {
-                                editorPart.doSave( monitor );
+                                editorPart.doSave(monitor);
                             }
                             else
                             {
@@ -76,18 +76,17 @@
                         }
                     }
                 };
-                new ProgressMonitorDialog( shell ).run( false, true, saveOperation );
+                new ProgressMonitorDialog(shell).run(false, true, saveOperation);
 
                 // Execute on the file
                 IFile file = fileInput.getFile();
-                getResourceCommandHandler().execute( new IResource[]
-                    { file }, event );
+                getResourceCommandHandler().execute(new IResource[] { file }, event);
             }
-            catch ( InvocationTargetException e )
+            catch (InvocationTargetException e)
             {
-                throw new ExecutionException( "Error saving file", e.getTargetException() );
+                throw new ExecutionException("Error saving file", e.getTargetException());
             }
-            catch ( InterruptedException e )
+            catch (InterruptedException e)
             {
                 // Exit the command silently
             }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/IResourceCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/IResourceCommandHandler.java
index 56d1d2a..68350db 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/IResourceCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/IResourceCommandHandler.java
@@ -19,15 +19,13 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.handlers;
 
-
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.resources.IResource;
 
-
 public interface IResourceCommandHandler
 {
 
-    Object execute( IResource[] resources, ExecutionEvent event ) throws ExecutionException;
+    Object execute(IResource[] resources, ExecutionEvent event) throws ExecutionException;
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/SelectionResourceCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/SelectionResourceCommandHandler.java
index 00ebdba..3085ee1 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/SelectionResourceCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/SelectionResourceCommandHandler.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.handlers;
 
-
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.resources.IResource;
@@ -27,19 +26,18 @@
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.handlers.HandlerUtil;
 
-
 public abstract class SelectionResourceCommandHandler extends AbstractResourceCommandHandler
 {
 
-    public final Object execute( ExecutionEvent event ) throws ExecutionException
+    public final Object execute(ExecutionEvent event) throws ExecutionException
     {
-        ISelection selection = HandlerUtil.getCurrentSelection( event );
+        ISelection selection = HandlerUtil.getCurrentSelection(event);
 
-        Object[] objectArray = ( ( IStructuredSelection ) selection ).toArray();
+        Object[] objectArray = ((IStructuredSelection) selection).toArray();
         IResource[] resourceArray = new IResource[objectArray.length];
-        System.arraycopy( objectArray, 0, resourceArray, 0, objectArray.length );
+        System.arraycopy(objectArray, 0, resourceArray, 0, objectArray.length);
 
-        return getResourceCommandHandler().execute( resourceArray, event );
+        return getResourceCommandHandler().execute(resourceArray, event);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectCommandHandler.java
index 53d6417..1ac3e8b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectCommandHandler.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.handlers.project;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.eclipse.ui.SigilUI;
@@ -35,39 +34,40 @@
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 
-
 public class ConvertProjectCommandHandler implements IResourceCommandHandler
 {
 
-    public Object execute( IResource[] resources, ExecutionEvent event ) throws ExecutionException
+    public Object execute(IResource[] resources, ExecutionEvent event)
+        throws ExecutionException
     {
-        for ( IResource r : resources )
+        for (IResource r : resources)
         {
-            final IProject project = ( IProject ) r;
-            if ( project != null )
+            final IProject project = (IProject) r;
+            if (project != null)
             {
                 WorkspaceModifyOperation op = new WorkspaceModifyOperation()
                 {
                     @Override
-                    protected void execute( IProgressMonitor monitor ) throws CoreException
+                    protected void execute(IProgressMonitor monitor) throws CoreException
                     {
-                        SigilCore.makeSigilProject( project, monitor );
-                        IJavaProject java = JavaCore.create( project );
-                        ISigilProjectModel sigil = SigilCore.create( project );
+                        SigilCore.makeSigilProject(project, monitor);
+                        IJavaProject java = JavaCore.create(project);
+                        ISigilProjectModel sigil = SigilCore.create(project);
                         IClasspathEntry[] entries = java.getRawClasspath();
-                        for ( int i = 0; i < entries.length; i++ )
+                        for (int i = 0; i < entries.length; i++)
                         {
                             IClasspathEntry entry = entries[i];
-                            if ( entry.getEntryKind() == IClasspathEntry.CPE_SOURCE )
+                            if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
                             {
-                                String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry( entry );
-                                sigil.getBundle().addClasspathEntry( encodedClasspath );
+                                String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry(
+                                    entry);
+                                sigil.getBundle().addClasspathEntry(encodedClasspath);
                             }
                         }
-                        sigil.save( monitor );
+                        sigil.save(monitor);
                     }
                 };
-                SigilUI.runWorkspaceOperation( op, null );
+                SigilUI.runWorkspaceOperation(op, null);
             }
         }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectHandler.java
index 2bc47b1..919cc65 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectHandler.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.handlers.project;
 
-
 import org.apache.felix.sigil.eclipse.ui.internal.handlers.IResourceCommandHandler;
 import org.apache.felix.sigil.eclipse.ui.internal.handlers.SelectionResourceCommandHandler;
 
-
 public class ConvertProjectHandler extends SelectionResourceCommandHandler
 {
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathCommandHandler.java
index 5b82b32..27b49c4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathCommandHandler.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.handlers.project;
 
-
 import java.lang.reflect.InvocationTargetException;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
@@ -34,35 +33,36 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 
-
 public class RefreshSigilClasspathCommandHandler implements IResourceCommandHandler
 {
 
-    public Object execute( IResource[] resources, ExecutionEvent event ) throws ExecutionException
+    public Object execute(IResource[] resources, ExecutionEvent event)
+        throws ExecutionException
     {
         try
         {
-            for ( IResource res : resources )
+            for (IResource res : resources)
             {
-                IProject p = ( IProject ) res;
-                final ISigilProjectModel model = SigilCore.create( p );
+                IProject p = (IProject) res;
+                final ISigilProjectModel model = SigilCore.create(p);
 
                 WorkspaceModifyOperation op = new WorkspaceModifyOperation()
                 {
                     @Override
-                    protected void execute( IProgressMonitor monitor ) throws CoreException, InvocationTargetException,
+                    protected void execute(IProgressMonitor monitor)
+                        throws CoreException, InvocationTargetException,
                         InterruptedException
                     {
-                        model.resetClasspath( monitor );
+                        model.resetClasspath(monitor);
                     }
                 };
 
-                SigilUI.runWorkspaceOperation( op, null );
+                SigilUI.runWorkspaceOperation(op, null);
             }
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to create sigil project for refresh action", e );
+            SigilCore.error("Failed to create sigil project for refresh action", e);
         }
         return null;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathHandler.java
index e081dff..8c6317d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathHandler.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.handlers.project;
 
-
 import org.apache.felix.sigil.eclipse.ui.internal.handlers.IResourceCommandHandler;
 import org.apache.felix.sigil.eclipse.ui.internal.handlers.SelectionResourceCommandHandler;
 
-
 public class RefreshSigilClasspathHandler extends SelectionResourceCommandHandler
 {
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/perspective/SigilPerspectiveFactory.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/perspective/SigilPerspectiveFactory.java
index 1873a2b..de0bffe 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/perspective/SigilPerspectiveFactory.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/perspective/SigilPerspectiveFactory.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.perspective;
 
-
 import org.apache.felix.sigil.eclipse.ui.SigilUI;
 import org.eclipse.debug.ui.IDebugUIConstants;
 import org.eclipse.jdt.ui.JavaUI;
@@ -28,7 +27,6 @@
 import org.eclipse.ui.IPerspectiveFactory;
 import org.eclipse.ui.progress.IProgressConstants;
 
-
 public class SigilPerspectiveFactory implements IPerspectiveFactory
 {
 
@@ -36,7 +34,7 @@
     private static final String ID_SEARCH_VIEW = "org.eclipse.search.ui.views.SearchView"; //$NON-NLS-1$
     private static final String ID_CONSOLE_VIEW = "org.eclipse.ui.console.ConsoleView"; //$NON-NLS-1$
 
-    public void createInitialLayout( IPageLayout layout )
+    public void createInitialLayout(IPageLayout layout)
     {
         /*
          * Use ProjectExplorer vs PackageExplorer due to a bug with Drag and Drop on Mac OS X which affects PackageExplorer
@@ -44,66 +42,68 @@
          */
         String editorArea = layout.getEditorArea();
 
-        IFolderLayout folder = layout.createFolder( "left", IPageLayout.LEFT, ( float ) 0.25, editorArea ); //$NON-NLS-1$
-        folder.addView( ID_PROJECT_EXPLORER );
-        folder.addView( JavaUI.ID_TYPE_HIERARCHY );
-        folder.addPlaceholder( IPageLayout.ID_RES_NAV );
-        folder.addPlaceholder( SigilUI.ID_REPOSITORY_VIEW );
-        folder.addView( IPageLayout.ID_OUTLINE );
+        IFolderLayout folder = layout.createFolder(
+            "left", IPageLayout.LEFT, (float) 0.25, editorArea); //$NON-NLS-1$
+        folder.addView(ID_PROJECT_EXPLORER);
+        folder.addView(JavaUI.ID_TYPE_HIERARCHY);
+        folder.addPlaceholder(IPageLayout.ID_RES_NAV);
+        folder.addPlaceholder(SigilUI.ID_REPOSITORY_VIEW);
+        folder.addView(IPageLayout.ID_OUTLINE);
 
-        IFolderLayout outputfolder = layout.createFolder( "bottom", IPageLayout.BOTTOM, ( float ) 0.75, editorArea ); //$NON-NLS-1$
-        outputfolder.addView( IPageLayout.ID_PROBLEM_VIEW );
-        outputfolder.addView( JavaUI.ID_JAVADOC_VIEW );
-        outputfolder.addView( JavaUI.ID_SOURCE_VIEW );
-        outputfolder.addPlaceholder( ID_SEARCH_VIEW );
-        outputfolder.addPlaceholder( ID_CONSOLE_VIEW );
-        outputfolder.addPlaceholder( IPageLayout.ID_BOOKMARKS );
-        outputfolder.addPlaceholder( IProgressConstants.PROGRESS_VIEW_ID );
-        outputfolder.addPlaceholder( SigilUI.ID_DEPENDENCY_VIEW );
+        IFolderLayout outputfolder = layout.createFolder(
+            "bottom", IPageLayout.BOTTOM, (float) 0.75, editorArea); //$NON-NLS-1$
+        outputfolder.addView(IPageLayout.ID_PROBLEM_VIEW);
+        outputfolder.addView(JavaUI.ID_JAVADOC_VIEW);
+        outputfolder.addView(JavaUI.ID_SOURCE_VIEW);
+        outputfolder.addPlaceholder(ID_SEARCH_VIEW);
+        outputfolder.addPlaceholder(ID_CONSOLE_VIEW);
+        outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+        outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
+        outputfolder.addPlaceholder(SigilUI.ID_DEPENDENCY_VIEW);
 
-        layout.addActionSet( IDebugUIConstants.LAUNCH_ACTION_SET );
-        layout.addActionSet( JavaUI.ID_ACTION_SET );
-        layout.addActionSet( JavaUI.ID_ELEMENT_CREATION_ACTION_SET );
-        layout.addActionSet( IPageLayout.ID_NAVIGATE_ACTION_SET );
+        layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
+        layout.addActionSet(JavaUI.ID_ACTION_SET);
+        layout.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET);
+        layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
 
         // views - sigil
-        layout.addShowViewShortcut( SigilUI.ID_REPOSITORY_VIEW );
-        layout.addShowViewShortcut( SigilUI.ID_DEPENDENCY_VIEW );
+        layout.addShowViewShortcut(SigilUI.ID_REPOSITORY_VIEW);
+        layout.addShowViewShortcut(SigilUI.ID_DEPENDENCY_VIEW);
 
         // views - java
-        layout.addShowViewShortcut( JavaUI.ID_PACKAGES );
-        layout.addShowViewShortcut( JavaUI.ID_TYPE_HIERARCHY );
-        layout.addShowViewShortcut( JavaUI.ID_SOURCE_VIEW );
-        layout.addShowViewShortcut( JavaUI.ID_JAVADOC_VIEW );
+        layout.addShowViewShortcut(JavaUI.ID_PACKAGES);
+        layout.addShowViewShortcut(JavaUI.ID_TYPE_HIERARCHY);
+        layout.addShowViewShortcut(JavaUI.ID_SOURCE_VIEW);
+        layout.addShowViewShortcut(JavaUI.ID_JAVADOC_VIEW);
 
         // views - search
-        layout.addShowViewShortcut( ID_SEARCH_VIEW );
+        layout.addShowViewShortcut(ID_SEARCH_VIEW);
 
         // views - debugging
-        layout.addShowViewShortcut( ID_CONSOLE_VIEW );
+        layout.addShowViewShortcut(ID_CONSOLE_VIEW);
 
         // views - standard workbench
-        layout.addShowViewShortcut( IPageLayout.ID_OUTLINE );
-        layout.addShowViewShortcut( IPageLayout.ID_PROBLEM_VIEW );
-        layout.addShowViewShortcut( IPageLayout.ID_RES_NAV );
-        layout.addShowViewShortcut( IPageLayout.ID_TASK_LIST );
-        layout.addShowViewShortcut( IProgressConstants.PROGRESS_VIEW_ID );
-        layout.addShowViewShortcut( ID_PROJECT_EXPLORER );
+        layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+        layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+        layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
+        layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
+        layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
+        layout.addShowViewShortcut(ID_PROJECT_EXPLORER);
 
         // new actions - Java project creation wizard
-        layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewPackageCreationWizard" ); //$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewClassCreationWizard" ); //$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard" ); //$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewEnumCreationWizard" ); //$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard" ); //$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard" ); //$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard" ); //$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard" ); //$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.ui.wizards.new.folder" );//$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.ui.wizards.new.file" );//$NON-NLS-1$
-        layout.addNewWizardShortcut( "org.eclipse.ui.editors.wizards.UntitledTextFileWizard" );//$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewPackageCreationWizard"); //$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewClassCreationWizard"); //$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard"); //$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewEnumCreationWizard"); //$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard"); //$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard"); //$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard"); //$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard"); //$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
+        layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
 
-        layout.addNewWizardShortcut( "org.apache.felix.sigil.editors.newProjectWizard" );
+        layout.addNewWizardShortcut("org.apache.felix.sigil.editors.newProjectWizard");
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ExcludedResourcesPrefsPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ExcludedResourcesPrefsPage.java
index fb57f84..dca4767 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ExcludedResourcesPrefsPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ExcludedResourcesPrefsPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences;
 
-
 import java.util.ArrayList;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
@@ -46,7 +45,6 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
-
 public class ExcludedResourcesPrefsPage extends PreferencePage implements IWorkbenchPreferencePage
 {
 
@@ -54,145 +52,138 @@
     private IWorkbench workbench;
     private ArrayList<String> resources;
 
-
     public ExcludedResourcesPrefsPage()
     {
         super();
-        setDescription( "Specify resources that should not be offered for inclusion in a generated bundle." );
+        setDescription("Specify resources that should not be offered for inclusion in a generated bundle.");
     }
 
-
     @Override
-    protected Control createContents( Composite parent )
+    protected Control createContents(Composite parent)
     {
         // Create controls
-        Composite composite = new Composite( parent, SWT.NONE );
-        Table table = new Table( composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION );
+        Composite composite = new Composite(parent, SWT.NONE);
+        Table table = new Table(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
 
-        Button btnAdd = new Button( composite, SWT.PUSH );
-        btnAdd.setText( "Add" );
+        Button btnAdd = new Button(composite, SWT.PUSH);
+        btnAdd.setText("Add");
 
-        final Button btnRemove = new Button( composite, SWT.PUSH );
-        btnRemove.setText( "Remove" );
-        btnRemove.setEnabled( false );
+        final Button btnRemove = new Button(composite, SWT.PUSH);
+        btnRemove.setText("Remove");
+        btnRemove.setEnabled(false);
 
         // Create viewer
-        viewer = new TableViewer( table );
-        viewer.setContentProvider( new ArrayContentProvider() );
+        viewer = new TableViewer(table);
+        viewer.setContentProvider(new ArrayContentProvider());
 
         // Load data
-        loadPreferences( false );
-        viewer.setInput( resources );
+        loadPreferences(false);
+        viewer.setInput(resources);
 
         // Listeners
-        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        viewer.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
-                btnRemove.setEnabled( !viewer.getSelection().isEmpty() );
+                btnRemove.setEnabled(!viewer.getSelection().isEmpty());
             }
-        } );
+        });
 
-        btnRemove.addSelectionListener( new SelectionAdapter()
+        btnRemove.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                IStructuredSelection selection = ( IStructuredSelection ) viewer.getSelection();
+                IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                 Object[] deleted = selection.toArray();
-                for ( Object delete : deleted )
+                for (Object delete : deleted)
                 {
-                    resources.remove( delete );
+                    resources.remove(delete);
                 }
-                viewer.remove( deleted );
+                viewer.remove(deleted);
             }
-        } );
+        });
 
-        btnAdd.addSelectionListener( new SelectionAdapter()
+        btnAdd.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                InputDialog dialog = new InputDialog( getShell(), "Add Resource", "Enter resource name", "",
-                    new IInputValidator()
+                InputDialog dialog = new InputDialog(getShell(), "Add Resource",
+                    "Enter resource name", "", new IInputValidator()
                     {
-                        public String isValid( String newText )
+                        public String isValid(String newText)
                         {
                             String error = null;
-                            if ( newText == null || newText.length() == 0 )
+                            if (newText == null || newText.length() == 0)
                             {
                                 error = "Name must not be empty.";
                             }
-                            else if ( resources.contains( newText ) )
+                            else if (resources.contains(newText))
                             {
                                 error = "Specified resource name is already on the list.";
                             }
                             return error;
                         }
-                    } );
+                    });
 
-                if ( dialog.open() == Window.OK )
+                if (dialog.open() == Window.OK)
                 {
                     String value = dialog.getValue();
-                    resources.add( value );
-                    viewer.add( value );
+                    resources.add(value);
+                    viewer.add(value);
                 }
             }
-        } );
+        });
 
         // Layout
-        composite.setLayout( new GridLayout( 2, false ) );
-        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 ) );
-        btnAdd.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
-        btnRemove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+        composite.setLayout(new GridLayout(2, false));
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
+        btnAdd.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
 
         return composite;
     }
 
-
-    private void loadPreferences( boolean useDefaults )
+    private void loadPreferences(boolean useDefaults)
     {
         String resourcesListStr = useDefaults ? getPreferenceStore().getDefaultString(
-            SigilCore.DEFAULT_EXCLUDED_RESOURCES ) : getPreferenceStore().getString(
-            SigilCore.DEFAULT_EXCLUDED_RESOURCES );
-        String[] resourcesArray = PrefsUtils.stringToArray( resourcesListStr );
+            SigilCore.DEFAULT_EXCLUDED_RESOURCES) : getPreferenceStore().getString(
+            SigilCore.DEFAULT_EXCLUDED_RESOURCES);
+        String[] resourcesArray = PrefsUtils.stringToArray(resourcesListStr);
 
-        resources = new ArrayList<String>( resourcesArray.length );
-        for ( String resource : resourcesArray )
+        resources = new ArrayList<String>(resourcesArray.length);
+        for (String resource : resourcesArray)
         {
-            resources.add( resource );
+            resources.add(resource);
         }
     }
 
-
-    public void init( IWorkbench workbench )
+    public void init(IWorkbench workbench)
     {
         this.workbench = workbench;
     }
 
-
     @Override
     protected IPreferenceStore doGetPreferenceStore()
     {
         return SigilCore.getDefault().getPreferenceStore();
     }
 
-
     @Override
     public boolean performOk()
     {
-        String resourcesStr = PrefsUtils.arrayToString( resources.toArray( new String[resources.size()] ) );
-        getPreferenceStore().setValue( SigilCore.DEFAULT_EXCLUDED_RESOURCES, resourcesStr );
+        String resourcesStr = PrefsUtils.arrayToString(resources.toArray(new String[resources.size()]));
+        getPreferenceStore().setValue(SigilCore.DEFAULT_EXCLUDED_RESOURCES, resourcesStr);
         return true;
     }
 
-
     @Override
     protected void performDefaults()
     {
         super.performDefaults();
-        loadPreferences( true );
-        viewer.setInput( resources );
+        loadPreferences(true);
+        viewer.setInput(resources);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryConfigurationDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryConfigurationDialog.java
index 652f75f..c0c85eb 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryConfigurationDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryConfigurationDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences;
 
-
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.TreeSet;
@@ -54,21 +53,21 @@
 import org.eclipse.swt.widgets.Text;
 import org.osgi.framework.Version;
 
-
 public class LibraryConfigurationDialog extends TitleAreaDialog
 {
 
     private static final Comparator<IPackageImport> COMPARATOR = new Comparator<IPackageImport>()
     {
-        public int compare( IPackageImport o1, IPackageImport o2 )
+        public int compare(IPackageImport o1, IPackageImport o2)
         {
-            return o1.getPackageName().compareTo( o2.getPackageName() );
+            return o1.getPackageName().compareTo(o2.getPackageName());
         }
     };
 
     private String name;
     private Version version;
-    private TreeSet<IPackageImport> packageImports = new TreeSet<IPackageImport>( COMPARATOR );
+    private TreeSet<IPackageImport> packageImports = new TreeSet<IPackageImport>(
+        COMPARATOR);
 
     private boolean editOnly;
 
@@ -76,146 +75,142 @@
     private Text txtName;
     private Text txtVersion;
 
-
-    public LibraryConfigurationDialog( Shell parentShell )
+    public LibraryConfigurationDialog(Shell parentShell)
     {
-        super( parentShell );
+        super(parentShell);
         name = "";
         version = Version.emptyVersion;
     }
 
-
-    public LibraryConfigurationDialog( Shell parentShell, ILibrary lib )
+    public LibraryConfigurationDialog(Shell parentShell, ILibrary lib)
     {
-        super( parentShell );
+        super(parentShell);
         editOnly = true;
         name = lib.getName();
         version = lib.getVersion();
-        packageImports.addAll( lib.getImports() );
+        packageImports.addAll(lib.getImports());
     }
 
-
     @Override
-    protected Control createDialogArea( Composite par )
+    protected Control createDialogArea(Composite par)
     {
-        setTitle( "Add Library" );
-        Composite container = ( Composite ) super.createDialogArea( par );
+        setTitle("Add Library");
+        Composite container = (Composite) super.createDialogArea(par);
 
-        Composite topPanel = new Composite( container, SWT.NONE );
+        Composite topPanel = new Composite(container, SWT.NONE);
 
-        new Label( topPanel, SWT.NONE ).setText( "Name" );
+        new Label(topPanel, SWT.NONE).setText("Name");
 
-        txtName = new Text( topPanel, SWT.BORDER );
-        txtName.setEditable( !editOnly );
-        if ( name != null )
-            txtName.setText( name );
+        txtName = new Text(topPanel, SWT.BORDER);
+        txtName.setEditable(!editOnly);
+        if (name != null)
+            txtName.setText(name);
 
-        new Label( topPanel, SWT.NONE ).setText( "Version" );
+        new Label(topPanel, SWT.NONE).setText("Version");
 
-        txtVersion = new Text( topPanel, SWT.BORDER );
-        txtVersion.setText( version.toString() );
-        txtVersion.setEditable( !editOnly );
+        txtVersion = new Text(topPanel, SWT.BORDER);
+        txtVersion.setText(version.toString());
+        txtVersion.setEditable(!editOnly);
 
-        Composite bottomPanel = new Composite( container, SWT.NONE );
+        Composite bottomPanel = new Composite(container, SWT.NONE);
 
-        Table table = new Table( bottomPanel, SWT.BORDER );
-        table.setSize( new Point( 300, 200 ) );
+        Table table = new Table(bottomPanel, SWT.BORDER);
+        table.setSize(new Point(300, 200));
 
-        Button add = new Button( bottomPanel, SWT.PUSH );
-        add.setText( "Add..." );
+        Button add = new Button(bottomPanel, SWT.PUSH);
+        add.setText("Add...");
 
-        final Button edit = new Button( bottomPanel, SWT.PUSH );
-        edit.setText( "Edit..." );
-        edit.setEnabled( false );
+        final Button edit = new Button(bottomPanel, SWT.PUSH);
+        edit.setText("Edit...");
+        edit.setEnabled(false);
 
-        final Button remove = new Button( bottomPanel, SWT.PUSH );
-        remove.setText( "Remove" );
-        remove.setEnabled( false );
+        final Button remove = new Button(bottomPanel, SWT.PUSH);
+        remove.setText("Remove");
+        remove.setEnabled(false);
 
         updateState();
 
         // Hookup Listeners
-        txtName.addModifyListener( new ModifyListener()
+        txtName.addModifyListener(new ModifyListener()
         {
-            public void modifyText( ModifyEvent e )
+            public void modifyText(ModifyEvent e)
             {
                 updateState();
             }
-        } );
-        txtVersion.addModifyListener( new ModifyListener()
+        });
+        txtVersion.addModifyListener(new ModifyListener()
         {
-            public void modifyText( ModifyEvent e )
+            public void modifyText(ModifyEvent e)
             {
                 updateState();
             }
-        } );
-        add.addSelectionListener( new SelectionAdapter()
+        });
+        add.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleAdd();
             }
-        } );
-        edit.addSelectionListener( new SelectionAdapter()
+        });
+        edit.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleEdit();
             }
-        } );
-        remove.addSelectionListener( new SelectionAdapter()
+        });
+        remove.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleRemove();
             }
-        } );
+        });
 
         // Layout
-        topPanel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        topPanel.setLayout( new GridLayout( 2, false ) );
-        txtName.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        txtVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+        topPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        topPanel.setLayout(new GridLayout(2, false));
+        txtName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
 
-        bottomPanel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
-        bottomPanel.setLayout( new GridLayout( 2, false ) );
-        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 4 ) );
-        add.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
-        edit.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
-        remove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+        bottomPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        bottomPanel.setLayout(new GridLayout(2, false));
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
+        add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        edit.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
 
         // Table Viewer
-        viewer = new TableViewer( table );
-        viewer.setLabelProvider( new LabelProvider()
+        viewer = new TableViewer(table);
+        viewer.setLabelProvider(new LabelProvider()
         {
             @Override
-            public String getText( Object element )
+            public String getText(Object element)
             {
-                IPackageImport pi = ( IPackageImport ) element;
+                IPackageImport pi = (IPackageImport) element;
                 return pi.getPackageName() + " " + pi.getVersions();
             }
-        } );
-        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        });
+        viewer.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
-                edit.setEnabled( !event.getSelection().isEmpty() );
-                remove.setEnabled( !event.getSelection().isEmpty() );
+                edit.setEnabled(!event.getSelection().isEmpty());
+                remove.setEnabled(!event.getSelection().isEmpty());
             }
-        } );
-        viewer.setContentProvider( new DefaultTableProvider()
+        });
+        viewer.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
+        });
 
-        viewer.setInput( packageImports );
+        viewer.setInput(packageImports);
         return container;
     }
 
-
     private void updateState()
     {
         String error = null;
@@ -225,45 +220,43 @@
 
         try
         {
-            version = VersionTable.getVersion( txtVersion.getText() );
-            if ( version.getQualifier().indexOf( '_' ) > -1 )
+            version = VersionTable.getVersion(txtVersion.getText());
+            if (version.getQualifier().indexOf('_') > -1)
             {
                 warning = "The use of underscores in a version qualifier is discouraged.";
             }
         }
-        catch ( IllegalArgumentException e )
+        catch (IllegalArgumentException e)
         {
             version = null;
             error = "Invalid version format";
         }
 
-        Button okButton = getButton( IDialogConstants.OK_ID );
-        if ( okButton != null && !okButton.isDisposed() )
-            okButton.setEnabled( allowOkay() );
+        Button okButton = getButton(IDialogConstants.OK_ID);
+        if (okButton != null && !okButton.isDisposed())
+            okButton.setEnabled(allowOkay());
 
-        setErrorMessage( error );
-        setMessage( warning, IMessageProvider.WARNING );
+        setErrorMessage(error);
+        setMessage(warning, IMessageProvider.WARNING);
     }
 
-
     private boolean allowOkay()
     {
         return name != null && name.length() > 0 && version != null;
     }
 
-
     @Override
-    protected Button createButton( Composite parent, int id, String label, boolean defaultButton )
+    protected Button createButton(Composite parent, int id, String label,
+        boolean defaultButton)
     {
-        Button button = super.createButton( parent, id, label, defaultButton );
-        if ( id == IDialogConstants.OK_ID )
+        Button button = super.createButton(parent, id, label, defaultButton);
+        if (id == IDialogConstants.OK_ID)
         {
-            button.setEnabled( allowOkay() );
+            button.setEnabled(allowOkay());
         }
         return button;
     }
 
-
     private void handleAdd()
     {
         /*NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog(getShell(), "Add Imported Package", null, packageImports);
@@ -278,7 +271,6 @@
         }*/
     }
 
-
     private void handleEdit()
     {
         /*IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
@@ -312,33 +304,32 @@
         } */
     }
 
-
     private void handleRemove()
     {
-        IStructuredSelection selection = ( IStructuredSelection ) viewer.getSelection();
+        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
 
-        if ( !selection.isEmpty() )
+        if (!selection.isEmpty())
         {
-            for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); )
+            for (Iterator<IPackageImport> i = selection.iterator(); i.hasNext();)
             {
-                packageImports.remove( i.next() );
+                packageImports.remove(i.next());
             }
 
             viewer.refresh();
         }
     }
 
-
     public ILibrary getLibrary()
     {
-        ILibrary library = ModelElementFactory.getInstance().newModelElement( ILibrary.class );
+        ILibrary library = ModelElementFactory.getInstance().newModelElement(
+            ILibrary.class);
 
-        library.setName( name );
-        library.setVersion( version );
+        library.setName(name);
+        library.setVersion(version);
 
-        for ( IPackageImport pi : packageImports )
+        for (IPackageImport pi : packageImports)
         {
-            library.addImport( pi );
+            library.addImport(pi);
         }
 
         return library;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryPreferencePage.java
index 348de4b..a93cd33 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryPreferencePage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences;
 
-
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.TreeSet;
@@ -50,7 +49,6 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
-
 public class LibraryPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
 {
 
@@ -62,227 +60,216 @@
     private Button btnEdit;
     private Button btnRemove;
 
-
-    public void init( IWorkbench workbench )
+    public void init(IWorkbench workbench)
     {
     }
 
-
     @Override
-    protected Control createContents( Composite parent )
+    protected Control createContents(Composite parent)
     {
-        Control control = initContents( parent );
+        Control control = initContents(parent);
         loadPreferences();
         return control;
     }
 
-
     @Override
     protected IPreferenceStore doGetPreferenceStore()
     {
         return SigilCore.getDefault().getPreferenceStore();
     }
 
-
     @Override
     protected void performDefaults()
     {
         super.performDefaults();
     }
 
-
     @Override
     public boolean performOk()
     {
         IPreferenceStore prefs = getPreferenceStore();
-        for ( String key : prefs.getString( SigilCore.LIBRARY_KEYS_PREF ).split( "," ) )
+        for (String key : prefs.getString(SigilCore.LIBRARY_KEYS_PREF).split(","))
         {
-            prefs.setToDefault( key );
+            prefs.setToDefault(key);
         }
 
         StringBuffer keys = new StringBuffer();
 
-        for ( ILibrary lib : libraries )
+        for (ILibrary lib : libraries)
         {
-            throw new IllegalStateException( "XXX-FIXME-XXX" );
+            throw new IllegalStateException("XXX-FIXME-XXX");
         }
 
-        prefs.setValue( SigilCore.LIBRARY_KEYS_PREF, keys.toString() );
+        prefs.setValue(SigilCore.LIBRARY_KEYS_PREF, keys.toString());
 
         return true;
     }
 
-
-    private Control initContents( Composite parent )
+    private Control initContents(Composite parent)
     {
-        Composite control = new Composite( parent, SWT.NONE );
-        control.setFont( parent.getFont() );
+        Composite control = new Composite(parent, SWT.NONE);
+        control.setFont(parent.getFont());
 
-        GridLayout grid = new GridLayout( 3, false );
-        control.setLayout( grid );
+        GridLayout grid = new GridLayout(3, false);
+        control.setLayout(grid);
 
-        initRepositories( control );
+        initRepositories(control);
 
         return control;
     }
 
-
-    private void initRepositories( Composite composite )
+    private void initRepositories(Composite composite)
     {
         // Create controls
-        new Label( composite, SWT.NONE ).setText( "Libraries:" );
-        new Label( composite, SWT.NONE ); // Spacer
-        table = new Table( composite, SWT.SINGLE | SWT.BORDER );
+        new Label(composite, SWT.NONE).setText("Libraries:");
+        new Label(composite, SWT.NONE); // Spacer
+        table = new Table(composite, SWT.SINGLE | SWT.BORDER);
         //table.setFont(control.getFont());
-        btnAdd = new Button( composite, SWT.PUSH );
-        btnAdd.setText( "Add..." );
+        btnAdd = new Button(composite, SWT.PUSH);
+        btnAdd.setText("Add...");
         //add.setFont(control.getFont());
-        btnEdit = new Button( composite, SWT.PUSH );
-        btnEdit.setText( "Edit..." );
+        btnEdit = new Button(composite, SWT.PUSH);
+        btnEdit.setText("Edit...");
         //edit.setFont(control.getFont());
-        btnRemove = new Button( composite, SWT.PUSH );
-        btnRemove.setText( "Remove" );
+        btnRemove = new Button(composite, SWT.PUSH);
+        btnRemove.setText("Remove");
         //remove.setFont(control.getFont());
 
         // Table Model
-        libraries = new TreeSet<ILibrary>( new Comparator<ILibrary>()
+        libraries = new TreeSet<ILibrary>(new Comparator<ILibrary>()
         {
-            public int compare( ILibrary l1, ILibrary l2 )
+            public int compare(ILibrary l1, ILibrary l2)
             {
-                int c = l1.getName().compareTo( l2.getName() );
-                if ( c == 0 )
+                int c = l1.getName().compareTo(l2.getName());
+                if (c == 0)
                 {
-                    c = l1.getVersion().compareTo( l2.getVersion() );
+                    c = l1.getVersion().compareTo(l2.getVersion());
                 }
                 return c;
             }
-        } );
-        libraryView = new TableViewer( table );
-        libraryView.setLabelProvider( new LabelProvider()
+        });
+        libraryView = new TableViewer(table);
+        libraryView.setLabelProvider(new LabelProvider()
         {
-            public String getText( Object element )
+            public String getText(Object element)
             {
-                ILibrary rep = ( ILibrary ) element;
+                ILibrary rep = (ILibrary) element;
                 return rep.getName() + " " + rep.getVersion();
             }
-        } );
-        libraryView.setContentProvider( new DefaultTableProvider()
+        });
+        libraryView.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
-        libraryView.setInput( libraries );
+        });
+        libraryView.setInput(libraries);
 
         // Initialize controls
         updateButtonStates();
 
         // Hookup Listeners
-        libraryView.addSelectionChangedListener( new ISelectionChangedListener()
+        libraryView.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
                 updateButtonStates();
             }
-        } );
-        btnAdd.addSelectionListener( new SelectionAdapter()
+        });
+        btnAdd.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleAdd();
             }
-        } );
-        btnEdit.addSelectionListener( new SelectionAdapter()
+        });
+        btnEdit.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleEdit();
             }
-        } );
-        btnRemove.addSelectionListener( new SelectionAdapter()
+        });
+        btnRemove.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleRemove();
             }
-        } );
+        });
 
         // Layout
-        composite.setLayout( new GridLayout( 2, false ) );
-        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 4 ) );
-        GridDataFactory buttonGD = GridDataFactory.swtDefaults().align( SWT.FILL, SWT.CENTER );
-        btnAdd.setLayoutData( buttonGD.create() );
-        btnEdit.setLayoutData( buttonGD.create() );
-        btnRemove.setLayoutData( buttonGD.create() );
+        composite.setLayout(new GridLayout(2, false));
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
+        GridDataFactory buttonGD = GridDataFactory.swtDefaults().align(SWT.FILL,
+            SWT.CENTER);
+        btnAdd.setLayoutData(buttonGD.create());
+        btnEdit.setLayoutData(buttonGD.create());
+        btnRemove.setLayoutData(buttonGD.create());
     }
 
-
     private void updateButtonStates()
     {
         ISelection sel = libraryView.getSelection();
-        btnEdit.setEnabled( !sel.isEmpty() );
-        btnRemove.setEnabled( !sel.isEmpty() );
+        btnEdit.setEnabled(!sel.isEmpty());
+        btnRemove.setEnabled(!sel.isEmpty());
     }
 
-
     private void handleAdd()
     {
-        LibraryConfigurationDialog d = new LibraryConfigurationDialog( getShell() );
-        if ( d.open() == Window.OK )
+        LibraryConfigurationDialog d = new LibraryConfigurationDialog(getShell());
+        if (d.open() == Window.OK)
         {
-            libraries.add( d.getLibrary() );
+            libraries.add(d.getLibrary());
             libraryView.refresh();
         }
     }
 
-
     private void handleEdit()
     {
-        IStructuredSelection sel = ( IStructuredSelection ) libraryView.getSelection();
+        IStructuredSelection sel = (IStructuredSelection) libraryView.getSelection();
         boolean change = false;
 
-        for ( @SuppressWarnings("unchecked")
-        Iterator<ILibrary> i = sel.iterator(); i.hasNext(); )
+        for (@SuppressWarnings("unchecked")
+        Iterator<ILibrary> i = sel.iterator(); i.hasNext();)
         {
             ILibrary lib = i.next();
-            LibraryConfigurationDialog d = new LibraryConfigurationDialog( getShell(), lib );
-            if ( d.open() == Window.OK )
+            LibraryConfigurationDialog d = new LibraryConfigurationDialog(getShell(), lib);
+            if (d.open() == Window.OK)
             {
-                libraries.remove( lib );
-                libraries.add( d.getLibrary() );
+                libraries.remove(lib);
+                libraries.add(d.getLibrary());
                 change = true;
             }
         }
 
-        if ( change )
+        if (change)
         {
             libraryView.refresh();
         }
     }
 
-
     private void handleRemove()
     {
-        IStructuredSelection sel = ( IStructuredSelection ) libraryView.getSelection();
-        for ( @SuppressWarnings("unchecked")
-        Iterator<ILibrary> i = sel.iterator(); i.hasNext(); )
+        IStructuredSelection sel = (IStructuredSelection) libraryView.getSelection();
+        for (@SuppressWarnings("unchecked")
+        Iterator<ILibrary> i = sel.iterator(); i.hasNext();)
         {
-            libraries.remove( i );
+            libraries.remove(i);
         }
         libraryView.refresh();
     }
 
-
     private void loadPreferences()
     {
         IPreferenceStore prefs = getPreferenceStore();
-        String keys = prefs.getString( SigilCore.LIBRARY_KEYS_PREF );
-        if ( keys.trim().length() > 0 )
+        String keys = prefs.getString(SigilCore.LIBRARY_KEYS_PREF);
+        if (keys.trim().length() > 0)
         {
-            for ( String key : keys.split( "," ) )
+            for (String key : keys.split(","))
             {
-                String libStr = prefs.getString( key );
+                String libStr = prefs.getString(key);
                 // XXX-FIXME-XXX parse library string
                 // lib = parse(libstr);
                 // libraries.add(lib);
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/OptionalPrompt.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/OptionalPrompt.java
index d4d739a..2b5f22f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/OptionalPrompt.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/OptionalPrompt.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.preferences.PromptablePreference;
 import org.eclipse.jface.dialogs.IDialogConstants;
@@ -27,21 +26,22 @@
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.widgets.Shell;
 
-
 public class OptionalPrompt
 {
-    public static boolean optionallyPrompt( String prefName, String title, String text, Shell parentShell) 
+    public static boolean optionallyPrompt(String prefName, String title, String text,
+        Shell parentShell)
     {
-        return optionallyPrompt(SigilCore.getDefault().getPreferenceStore(), prefName, title, text, parentShell);
+        return optionallyPrompt(SigilCore.getDefault().getPreferenceStore(), prefName,
+            title, text, parentShell);
     }
-    
-    public static boolean optionallyPrompt( IPreferenceStore prefStore, String prefName, String title, String text,
-        Shell parentShell )
+
+    public static boolean optionallyPrompt(IPreferenceStore prefStore, String prefName,
+        String title, String text, Shell parentShell)
     {
         boolean result = false;
 
         PromptablePreference value = preference(prefStore, prefName);
-        switch ( value )
+        switch (value)
         {
             case Always:
                 result = true;
@@ -50,33 +50,35 @@
                 result = false;
                 break;
             case Prompt:
-                MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( parentShell, title, text,
-                    "Do not ask this again", false, null, null );
-                result = ( dialog.getReturnCode() == IDialogConstants.YES_ID );
-                if ( dialog.getToggleState() )
+                MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
+                    parentShell, title, text, "Do not ask this again", false, null, null);
+                result = (dialog.getReturnCode() == IDialogConstants.YES_ID);
+                if (dialog.getToggleState())
                 {
                     // User said don't ask again... take the current answer as the new preference
-                    prefStore.setValue( prefName, result ? PromptablePreference.Always.name()
-                        : PromptablePreference.Never.name() );
+                    prefStore.setValue(prefName,
+                        result ? PromptablePreference.Always.name()
+                            : PromptablePreference.Never.name());
                 }
         }
 
         return result;
     }
 
-    public static int optionallyPromptWithCancel( String prefName, String title,
-        String text, Shell parentShell )
+    public static int optionallyPromptWithCancel(String prefName, String title,
+        String text, Shell parentShell)
     {
-        return optionallyPromptWithCancel(SigilCore.getDefault().getPreferenceStore(), prefName, title, text, parentShell);
+        return optionallyPromptWithCancel(SigilCore.getDefault().getPreferenceStore(),
+            prefName, title, text, parentShell);
     }
-    
-    public static int optionallyPromptWithCancel( IPreferenceStore prefStore, String prefName, String title,
-        String text, Shell parentShell )
+
+    public static int optionallyPromptWithCancel(IPreferenceStore prefStore,
+        String prefName, String title, String text, Shell parentShell)
     {
         int result = IDialogConstants.NO_ID;
 
         PromptablePreference value = preference(prefStore, prefName);
-        switch ( value )
+        switch (value)
         {
             case Always:
                 result = IDialogConstants.YES_ID;
@@ -85,32 +87,35 @@
                 result = IDialogConstants.NO_ID;
                 break;
             case Prompt:
-                MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion( parentShell, title,
-                    text, "Do not ask this again", false, null, null );
+                MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(
+                    parentShell, title, text, "Do not ask this again", false, null, null);
                 result = dialog.getReturnCode();
-                if ( result != IDialogConstants.CANCEL_ID )
+                if (result != IDialogConstants.CANCEL_ID)
                 {
-                    if ( dialog.getToggleState() )
+                    if (dialog.getToggleState())
                     {
                         // User said don't ask again... take the current answer as the new preference
-                        prefStore.setValue( prefName,
-                            ( result == IDialogConstants.YES_ID ) ? PromptablePreference.Always.name()
-                                : PromptablePreference.Never.name() );
+                        prefStore.setValue(
+                            prefName,
+                            (result == IDialogConstants.YES_ID) ? PromptablePreference.Always.name()
+                                : PromptablePreference.Never.name());
                     }
                 }
         }
 
         return result;
     }
-    
+
     /**
      * @param prefStore 
      * @param prefName
      * @return
      */
-    private static PromptablePreference preference(IPreferenceStore prefStore, String prefName)
+    private static PromptablePreference preference(IPreferenceStore prefStore,
+        String prefName)
     {
-        String val = prefStore.getString( prefName );
-        return (val == null || val.trim().length() == 0) ? PromptablePreference.Prompt : PromptablePreference.valueOf( val );
-    }    
+        String val = prefStore.getString(prefName);
+        return (val == null || val.trim().length() == 0) ? PromptablePreference.Prompt
+            : PromptablePreference.valueOf(val);
+    }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ProjectDependentPreferencesPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ProjectDependentPreferencesPage.java
index d9a7aa7..b738194 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ProjectDependentPreferencesPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ProjectDependentPreferencesPage.java
@@ -19,33 +19,30 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences;
 
-
 import org.apache.felix.sigil.eclipse.ui.util.ProjectUtils;
 import org.eclipse.jface.preference.PreferencePage;
 
-
 public abstract class ProjectDependentPreferencesPage extends PreferencePage
 {
 
-    public ProjectDependentPreferencesPage( String title )
+    public ProjectDependentPreferencesPage(String title)
     {
-        super( title );
+        super(title);
     }
 
-
     @Override
     public boolean performOk()
     {
-        if ( isDirty() )
+        if (isDirty())
         {
-            return ProjectUtils.runTaskWithRebuildCheck( new Runnable()
+            return ProjectUtils.runTaskWithRebuildCheck(new Runnable()
             {
                 public void run()
                 {
                     doSave();
                 }
 
-            }, getShell() );
+            }, getShell());
         }
         else
         {
@@ -53,9 +50,7 @@
         }
     }
 
-
     protected abstract void doSave();
 
-
     protected abstract boolean isDirty();
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/SigilPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/SigilPreferencePage.java
index bd34121..6f68eb4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/SigilPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/SigilPreferencePage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.preferences.PromptablePreference;
 import org.eclipse.jface.preference.FieldEditorPreferencePage;
@@ -28,41 +27,42 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
-
 public class SigilPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
 {
 
     @Override
     protected void createFieldEditors()
     {
-        RadioGroupFieldEditor impExpField = new RadioGroupFieldEditor( SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT,
-            "Add Imports for New Exports", 1, new String[][]
-                { new String[]
-                    { "Always (Recommended)", PromptablePreference.Always.toString() }, new String[]
-                    { "Prompt", PromptablePreference.Prompt.toString() }, new String[]
-                    { "Never", PromptablePreference.Never.toString() } }, getFieldEditorParent(), true );
+        RadioGroupFieldEditor impExpField = new RadioGroupFieldEditor(
+            SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT, "Add Imports for New Exports",
+            1, new String[][] {
+                    new String[] { "Always (Recommended)",
+                            PromptablePreference.Always.toString() },
+                    new String[] { "Prompt", PromptablePreference.Prompt.toString() },
+                    new String[] { "Never", PromptablePreference.Never.toString() } },
+            getFieldEditorParent(), true);
 
-        addField( impExpField );
+        addField(impExpField);
 
-        RadioGroupFieldEditor rebuildExpField = new RadioGroupFieldEditor( SigilCore.PREFERENCES_REBUILD_PROJECTS,
-            "Rebuild Projects On Install Change", 1, new String[][]
-                { new String[]
-                    { "Always (Recommended)", PromptablePreference.Always.toString() }, new String[]
-                    { "Prompt", PromptablePreference.Prompt.toString() }, new String[]
-                    { "Never", PromptablePreference.Never.toString() } }, getFieldEditorParent(), true );
+        RadioGroupFieldEditor rebuildExpField = new RadioGroupFieldEditor(
+            SigilCore.PREFERENCES_REBUILD_PROJECTS, "Rebuild Projects On Install Change",
+            1, new String[][] {
+                    new String[] { "Always (Recommended)",
+                            PromptablePreference.Always.toString() },
+                    new String[] { "Prompt", PromptablePreference.Prompt.toString() },
+                    new String[] { "Never", PromptablePreference.Never.toString() } },
+            getFieldEditorParent(), true);
 
-        addField( rebuildExpField );
+        addField(rebuildExpField);
     }
 
-
     @Override
     protected IPreferenceStore doGetPreferenceStore()
     {
         return SigilCore.getDefault().getPreferenceStore();
     }
 
-
-    public void init( IWorkbench workbench )
+    public void init(IWorkbench workbench)
     {
     }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/VersionsPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/VersionsPreferencePage.java
index a07d567..233ce5b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/VersionsPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/VersionsPreferencePage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences;
 
-
 import org.apache.felix.sigil.common.osgi.VersionRange;
 import org.apache.felix.sigil.common.osgi.VersionRangeBoundingRule;
 import org.apache.felix.sigil.common.osgi.VersionTable;
@@ -43,11 +42,11 @@
 import org.eclipse.ui.IWorkbenchPreferencePage;
 import org.osgi.framework.Version;
 
-
 public class VersionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
 {
 
-    private static final Version SAMPLE_VERSION = VersionTable.getVersion( 1, 2, 3, "qualifier" );
+    private static final Version SAMPLE_VERSION = VersionTable.getVersion(1, 2, 3,
+        "qualifier");
 
     private IWorkbench workbench;
 
@@ -74,361 +73,353 @@
     private Version sampleVersion = SAMPLE_VERSION;
     private Version matchVersion = null;
 
-
     public VersionsPreferencePage()
     {
         super();
-        setDescription( "Specify the Lower and Upper bounds for a default version range calculated from a point version, e.g. \"1.2.3.qualifier\"" );
+        setDescription("Specify the Lower and Upper bounds for a default version range calculated from a point version, e.g. \"1.2.3.qualifier\"");
     }
 
-
     @Override
-    protected Control createContents( Composite parent )
+    protected Control createContents(Composite parent)
     {
         // Create controls
-        Composite composite = new Composite( parent, SWT.NONE );
+        Composite composite = new Composite(parent, SWT.NONE);
 
-        Group grpLowerBound = new Group( composite, SWT.NONE );
-        grpLowerBound.setText( "Lower Bound" );
-        btnLowerBoundExact = new Button( grpLowerBound, SWT.RADIO );
-        btnLowerBoundExact.setText( "Exact e.g. [1.2.3.qualifer, ...)" );
-        btnLowerBoundMicro = new Button( grpLowerBound, SWT.RADIO );
-        btnLowerBoundMicro.setText( "Micro e.g. [1.2.3, ...)" );
-        btnLowerBoundMinor = new Button( grpLowerBound, SWT.RADIO );
-        btnLowerBoundMinor.setText( "Minor e.g. [1.2, ...)" );
-        btnLowerBoundMajor = new Button( grpLowerBound, SWT.RADIO );
-        btnLowerBoundMajor.setText( "Major e.g. [1, ...)" );
-        btnLowerBoundAny = new Button( grpLowerBound, SWT.RADIO );
-        btnLowerBoundAny.setText( "Any e.g. [0, ...)" );
+        Group grpLowerBound = new Group(composite, SWT.NONE);
+        grpLowerBound.setText("Lower Bound");
+        btnLowerBoundExact = new Button(grpLowerBound, SWT.RADIO);
+        btnLowerBoundExact.setText("Exact e.g. [1.2.3.qualifer, ...)");
+        btnLowerBoundMicro = new Button(grpLowerBound, SWT.RADIO);
+        btnLowerBoundMicro.setText("Micro e.g. [1.2.3, ...)");
+        btnLowerBoundMinor = new Button(grpLowerBound, SWT.RADIO);
+        btnLowerBoundMinor.setText("Minor e.g. [1.2, ...)");
+        btnLowerBoundMajor = new Button(grpLowerBound, SWT.RADIO);
+        btnLowerBoundMajor.setText("Major e.g. [1, ...)");
+        btnLowerBoundAny = new Button(grpLowerBound, SWT.RADIO);
+        btnLowerBoundAny.setText("Any e.g. [0, ...)");
 
-        Group grpUpperBound = new Group( composite, SWT.NONE );
-        grpUpperBound.setText( "Upper Bound" );
+        Group grpUpperBound = new Group(composite, SWT.NONE);
+        grpUpperBound.setText("Upper Bound");
 
-        btnUpperBoundExact = new Button( grpUpperBound, SWT.RADIO );
-        btnUpperBoundExact.setText( "Exact e.g. [..., 1.2.3.qualifer]" );
-        btnUpperBoundMicro = new Button( grpUpperBound, SWT.RADIO );
-        btnUpperBoundMicro.setText( "Micro e.g. [..., 1.2.4)" );
-        btnUpperBoundMinor = new Button( grpUpperBound, SWT.RADIO );
-        btnUpperBoundMinor.setText( "Minor e.g. [..., 1.3)" );
-        btnUpperBoundMajor = new Button( grpUpperBound, SWT.RADIO );
-        btnUpperBoundMajor.setText( "Major e.g. [..., 2)" );
-        btnUpperBoundAny = new Button( grpUpperBound, SWT.RADIO );
-        btnUpperBoundAny.setText( "Any e.g. [..., \u221e)" );
+        btnUpperBoundExact = new Button(grpUpperBound, SWT.RADIO);
+        btnUpperBoundExact.setText("Exact e.g. [..., 1.2.3.qualifer]");
+        btnUpperBoundMicro = new Button(grpUpperBound, SWT.RADIO);
+        btnUpperBoundMicro.setText("Micro e.g. [..., 1.2.4)");
+        btnUpperBoundMinor = new Button(grpUpperBound, SWT.RADIO);
+        btnUpperBoundMinor.setText("Minor e.g. [..., 1.3)");
+        btnUpperBoundMajor = new Button(grpUpperBound, SWT.RADIO);
+        btnUpperBoundMajor.setText("Major e.g. [..., 2)");
+        btnUpperBoundAny = new Button(grpUpperBound, SWT.RADIO);
+        btnUpperBoundAny.setText("Any e.g. [..., \u221e)");
 
-        Group grpRangeTest = new Group( composite, SWT.NONE );
-        grpRangeTest.setText( "Range Test" );
-        new Label( grpRangeTest, SWT.NONE ).setText( "Sample Input Version: " );
-        txtSampleVersion = new Text( grpRangeTest, SWT.BORDER );
-        new Label( grpRangeTest, SWT.NONE ).setText( "Calculated Version Range: " );
-        lblCalculatedRange = new Label( grpRangeTest, SWT.NONE );
+        Group grpRangeTest = new Group(composite, SWT.NONE);
+        grpRangeTest.setText("Range Test");
+        new Label(grpRangeTest, SWT.NONE).setText("Sample Input Version: ");
+        txtSampleVersion = new Text(grpRangeTest, SWT.BORDER);
+        new Label(grpRangeTest, SWT.NONE).setText("Calculated Version Range: ");
+        lblCalculatedRange = new Label(grpRangeTest, SWT.NONE);
 
-        new Label( grpRangeTest, SWT.NONE ).setText( "Test: " );
-        txtMatchVersion = new Text( grpRangeTest, SWT.BORDER );
-        new Label( grpRangeTest, SWT.NONE ).setText( "Result: " );
-        lblMatchResult = new Label( grpRangeTest, SWT.NONE );
+        new Label(grpRangeTest, SWT.NONE).setText("Test: ");
+        txtMatchVersion = new Text(grpRangeTest, SWT.BORDER);
+        new Label(grpRangeTest, SWT.NONE).setText("Result: ");
+        lblMatchResult = new Label(grpRangeTest, SWT.NONE);
 
         // Initialize controls
-        loadPreferences( false );
+        loadPreferences(false);
         updateRadioButtons();
 
-        txtSampleVersion.setText( sampleVersion.toString() );
+        txtSampleVersion.setText(sampleVersion.toString());
         updateCalculatedRange();
 
         // Add listeners
         SelectionListener buttonListener = new SelectionListener()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 readRadioButtons();
                 updateCalculatedRange();
             }
 
-
-            public void widgetDefaultSelected( SelectionEvent e )
+            public void widgetDefaultSelected(SelectionEvent e)
             {
                 readRadioButtons();
                 updateCalculatedRange();
             }
         };
-        btnLowerBoundAny.addSelectionListener( buttonListener );
-        btnLowerBoundMajor.addSelectionListener( buttonListener );
-        btnLowerBoundMinor.addSelectionListener( buttonListener );
-        btnLowerBoundMicro.addSelectionListener( buttonListener );
-        btnLowerBoundExact.addSelectionListener( buttonListener );
+        btnLowerBoundAny.addSelectionListener(buttonListener);
+        btnLowerBoundMajor.addSelectionListener(buttonListener);
+        btnLowerBoundMinor.addSelectionListener(buttonListener);
+        btnLowerBoundMicro.addSelectionListener(buttonListener);
+        btnLowerBoundExact.addSelectionListener(buttonListener);
 
-        btnUpperBoundAny.addSelectionListener( buttonListener );
-        btnUpperBoundMajor.addSelectionListener( buttonListener );
-        btnUpperBoundMinor.addSelectionListener( buttonListener );
-        btnUpperBoundMicro.addSelectionListener( buttonListener );
-        btnUpperBoundExact.addSelectionListener( buttonListener );
+        btnUpperBoundAny.addSelectionListener(buttonListener);
+        btnUpperBoundMajor.addSelectionListener(buttonListener);
+        btnUpperBoundMinor.addSelectionListener(buttonListener);
+        btnUpperBoundMicro.addSelectionListener(buttonListener);
+        btnUpperBoundExact.addSelectionListener(buttonListener);
 
-        txtSampleVersion.addModifyListener( new ModifyListener()
+        txtSampleVersion.addModifyListener(new ModifyListener()
         {
-            public void modifyText( ModifyEvent e )
+            public void modifyText(ModifyEvent e)
             {
                 try
                 {
-                    sampleVersion = VersionTable.getVersion( txtSampleVersion.getText() );
+                    sampleVersion = VersionTable.getVersion(txtSampleVersion.getText());
                 }
-                catch ( IllegalArgumentException x )
+                catch (IllegalArgumentException x)
                 {
                     sampleVersion = null;
                 }
                 updateCalculatedRange();
             }
-        } );
-        txtMatchVersion.addModifyListener( new ModifyListener()
+        });
+        txtMatchVersion.addModifyListener(new ModifyListener()
         {
-            public void modifyText( ModifyEvent e )
+            public void modifyText(ModifyEvent e)
             {
                 try
                 {
-                    matchVersion = VersionTable.getVersion( txtMatchVersion.getText() );
+                    matchVersion = VersionTable.getVersion(txtMatchVersion.getText());
                 }
-                catch ( IllegalArgumentException x )
+                catch (IllegalArgumentException x)
                 {
                     matchVersion = null;
                 }
                 updateCalculatedRange();
             }
-        } );
+        });
 
         // Layout
-        GridLayout layout = new GridLayout( 1, false );
+        GridLayout layout = new GridLayout(1, false);
         layout.verticalSpacing = 20;
-        composite.setLayout( layout );
+        composite.setLayout(layout);
 
-        grpLowerBound.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false ) );
-        grpLowerBound.setLayout( new GridLayout( 1, false ) );
+        grpLowerBound.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+        grpLowerBound.setLayout(new GridLayout(1, false));
 
-        grpUpperBound.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false ) );
-        grpUpperBound.setLayout( new GridLayout( 1, false ) );
+        grpUpperBound.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+        grpUpperBound.setLayout(new GridLayout(1, false));
 
-        grpRangeTest.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, true ) );
-        grpRangeTest.setLayout( new GridLayout( 2, false ) );
+        grpRangeTest.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+        grpRangeTest.setLayout(new GridLayout(2, false));
 
-        txtSampleVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        lblCalculatedRange.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        txtMatchVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        lblMatchResult.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+        txtSampleVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        lblCalculatedRange.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        txtMatchVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        lblMatchResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
 
         return composite;
     }
 
-
-    private void loadPreferences( boolean useDefaults )
+    private void loadPreferences(boolean useDefaults)
     {
         IPreferenceStore prefs = getPreferenceStore();
         String lowerBoundStr;
-        if ( useDefaults )
+        if (useDefaults)
         {
-            lowerBoundStr = prefs.getDefaultString( SigilCore.DEFAULT_VERSION_LOWER_BOUND );
+            lowerBoundStr = prefs.getDefaultString(SigilCore.DEFAULT_VERSION_LOWER_BOUND);
         }
         else
         {
-            lowerBoundStr = prefs.getString( SigilCore.DEFAULT_VERSION_LOWER_BOUND );
+            lowerBoundStr = prefs.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND);
         }
 
         String upperBoundStr;
-        if ( useDefaults )
+        if (useDefaults)
         {
-            upperBoundStr = prefs.getDefaultString( SigilCore.DEFAULT_VERSION_UPPER_BOUND );
+            upperBoundStr = prefs.getDefaultString(SigilCore.DEFAULT_VERSION_UPPER_BOUND);
         }
         else
         {
-            upperBoundStr = prefs.getString( SigilCore.DEFAULT_VERSION_UPPER_BOUND );
+            upperBoundStr = prefs.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND);
         }
 
-        lowerBoundRule = VersionRangeBoundingRule.valueOf( lowerBoundStr );
-        upperBoundRule = VersionRangeBoundingRule.valueOf( upperBoundStr );
+        lowerBoundRule = VersionRangeBoundingRule.valueOf(lowerBoundStr);
+        upperBoundRule = VersionRangeBoundingRule.valueOf(upperBoundStr);
     }
 
-
     private void updateRadioButtons()
     {
-        switch ( lowerBoundRule )
+        switch (lowerBoundRule)
         {
             case Exact:
-                btnLowerBoundExact.setSelection( true );
-                btnLowerBoundMicro.setSelection( false );
-                btnLowerBoundMinor.setSelection( false );
-                btnLowerBoundMajor.setSelection( false );
-                btnLowerBoundAny.setSelection( false );
+                btnLowerBoundExact.setSelection(true);
+                btnLowerBoundMicro.setSelection(false);
+                btnLowerBoundMinor.setSelection(false);
+                btnLowerBoundMajor.setSelection(false);
+                btnLowerBoundAny.setSelection(false);
                 break;
             case Micro:
-                btnLowerBoundExact.setSelection( false );
-                btnLowerBoundMicro.setSelection( true );
-                btnLowerBoundMinor.setSelection( false );
-                btnLowerBoundMajor.setSelection( false );
-                btnLowerBoundAny.setSelection( false );
+                btnLowerBoundExact.setSelection(false);
+                btnLowerBoundMicro.setSelection(true);
+                btnLowerBoundMinor.setSelection(false);
+                btnLowerBoundMajor.setSelection(false);
+                btnLowerBoundAny.setSelection(false);
                 break;
             case Minor:
-                btnLowerBoundExact.setSelection( false );
-                btnLowerBoundMicro.setSelection( false );
-                btnLowerBoundMinor.setSelection( true );
-                btnLowerBoundMajor.setSelection( false );
-                btnLowerBoundAny.setSelection( false );
+                btnLowerBoundExact.setSelection(false);
+                btnLowerBoundMicro.setSelection(false);
+                btnLowerBoundMinor.setSelection(true);
+                btnLowerBoundMajor.setSelection(false);
+                btnLowerBoundAny.setSelection(false);
                 break;
             case Major:
-                btnLowerBoundExact.setSelection( false );
-                btnLowerBoundMicro.setSelection( false );
-                btnLowerBoundMinor.setSelection( false );
-                btnLowerBoundMajor.setSelection( true );
-                btnLowerBoundAny.setSelection( false );
+                btnLowerBoundExact.setSelection(false);
+                btnLowerBoundMicro.setSelection(false);
+                btnLowerBoundMinor.setSelection(false);
+                btnLowerBoundMajor.setSelection(true);
+                btnLowerBoundAny.setSelection(false);
                 break;
             case Any:
-                btnLowerBoundExact.setSelection( false );
-                btnLowerBoundMicro.setSelection( false );
-                btnLowerBoundMinor.setSelection( false );
-                btnLowerBoundMajor.setSelection( false );
-                btnLowerBoundAny.setSelection( true );
+                btnLowerBoundExact.setSelection(false);
+                btnLowerBoundMicro.setSelection(false);
+                btnLowerBoundMinor.setSelection(false);
+                btnLowerBoundMajor.setSelection(false);
+                btnLowerBoundAny.setSelection(true);
                 break;
         }
 
-        switch ( upperBoundRule )
+        switch (upperBoundRule)
         {
             case Exact:
-                btnUpperBoundExact.setSelection( true );
-                btnUpperBoundMicro.setSelection( false );
-                btnUpperBoundMinor.setSelection( false );
-                btnUpperBoundMajor.setSelection( false );
-                btnUpperBoundAny.setSelection( false );
+                btnUpperBoundExact.setSelection(true);
+                btnUpperBoundMicro.setSelection(false);
+                btnUpperBoundMinor.setSelection(false);
+                btnUpperBoundMajor.setSelection(false);
+                btnUpperBoundAny.setSelection(false);
                 break;
             case Micro:
-                btnUpperBoundExact.setSelection( false );
-                btnUpperBoundMicro.setSelection( true );
-                btnUpperBoundMinor.setSelection( false );
-                btnUpperBoundMajor.setSelection( false );
-                btnUpperBoundAny.setSelection( false );
+                btnUpperBoundExact.setSelection(false);
+                btnUpperBoundMicro.setSelection(true);
+                btnUpperBoundMinor.setSelection(false);
+                btnUpperBoundMajor.setSelection(false);
+                btnUpperBoundAny.setSelection(false);
                 break;
             case Minor:
-                btnUpperBoundExact.setSelection( false );
-                btnUpperBoundMicro.setSelection( false );
-                btnUpperBoundMinor.setSelection( true );
-                btnUpperBoundMajor.setSelection( false );
-                btnUpperBoundAny.setSelection( false );
+                btnUpperBoundExact.setSelection(false);
+                btnUpperBoundMicro.setSelection(false);
+                btnUpperBoundMinor.setSelection(true);
+                btnUpperBoundMajor.setSelection(false);
+                btnUpperBoundAny.setSelection(false);
                 break;
             case Major:
-                btnUpperBoundExact.setSelection( false );
-                btnUpperBoundMicro.setSelection( false );
-                btnUpperBoundMinor.setSelection( false );
-                btnUpperBoundMajor.setSelection( true );
-                btnUpperBoundAny.setSelection( false );
+                btnUpperBoundExact.setSelection(false);
+                btnUpperBoundMicro.setSelection(false);
+                btnUpperBoundMinor.setSelection(false);
+                btnUpperBoundMajor.setSelection(true);
+                btnUpperBoundAny.setSelection(false);
                 break;
             case Any:
-                btnUpperBoundExact.setSelection( false );
-                btnUpperBoundMicro.setSelection( false );
-                btnUpperBoundMinor.setSelection( false );
-                btnUpperBoundMajor.setSelection( false );
-                btnUpperBoundAny.setSelection( true );
+                btnUpperBoundExact.setSelection(false);
+                btnUpperBoundMicro.setSelection(false);
+                btnUpperBoundMinor.setSelection(false);
+                btnUpperBoundMajor.setSelection(false);
+                btnUpperBoundAny.setSelection(true);
         }
     }
 
-
     private void readRadioButtons()
     {
-        if ( btnLowerBoundExact.getSelection() )
+        if (btnLowerBoundExact.getSelection())
         {
             lowerBoundRule = VersionRangeBoundingRule.Exact;
         }
-        else if ( btnLowerBoundMicro.getSelection() )
+        else if (btnLowerBoundMicro.getSelection())
         {
             lowerBoundRule = VersionRangeBoundingRule.Micro;
         }
-        else if ( btnLowerBoundMinor.getSelection() )
+        else if (btnLowerBoundMinor.getSelection())
         {
             lowerBoundRule = VersionRangeBoundingRule.Minor;
         }
-        else if ( btnLowerBoundMajor.getSelection() )
+        else if (btnLowerBoundMajor.getSelection())
         {
             lowerBoundRule = VersionRangeBoundingRule.Major;
         }
-        else if ( btnLowerBoundAny.getSelection() )
+        else if (btnLowerBoundAny.getSelection())
         {
             lowerBoundRule = VersionRangeBoundingRule.Any;
         }
 
-        if ( btnUpperBoundExact.getSelection() )
+        if (btnUpperBoundExact.getSelection())
         {
             upperBoundRule = VersionRangeBoundingRule.Exact;
         }
-        else if ( btnUpperBoundMicro.getSelection() )
+        else if (btnUpperBoundMicro.getSelection())
         {
             upperBoundRule = VersionRangeBoundingRule.Micro;
         }
-        else if ( btnUpperBoundMinor.getSelection() )
+        else if (btnUpperBoundMinor.getSelection())
         {
             upperBoundRule = VersionRangeBoundingRule.Minor;
         }
-        else if ( btnUpperBoundMajor.getSelection() )
+        else if (btnUpperBoundMajor.getSelection())
         {
             upperBoundRule = VersionRangeBoundingRule.Major;
         }
-        else if ( btnUpperBoundAny.getSelection() )
+        else if (btnUpperBoundAny.getSelection())
         {
             upperBoundRule = VersionRangeBoundingRule.Any;
         }
     }
 
-
     private void updateCalculatedRange()
     {
         VersionRange range;
         String rangeStr;
         String matchResult;
 
-        if ( sampleVersion == null )
+        if (sampleVersion == null)
         {
             range = null;
             rangeStr = "";
         }
         else
         {
-            range = VersionRange.newInstance( sampleVersion, lowerBoundRule, upperBoundRule );
+            range = VersionRange.newInstance(sampleVersion, lowerBoundRule,
+                upperBoundRule);
             rangeStr = range.toString();
         }
-        lblCalculatedRange.setText( rangeStr );
+        lblCalculatedRange.setText(rangeStr);
 
-        if ( matchVersion == null || range == null )
+        if (matchVersion == null || range == null)
         {
             matchResult = "";
         }
         else
         {
-            matchResult = range.contains( matchVersion ) ? "MATCH!" : "No Match";
+            matchResult = range.contains(matchVersion) ? "MATCH!" : "No Match";
         }
-        lblMatchResult.setText( matchResult );
+        lblMatchResult.setText(matchResult);
     }
 
-
-    public void init( IWorkbench workbench )
+    public void init(IWorkbench workbench)
     {
         this.workbench = workbench;
     }
 
-
     @Override
     protected IPreferenceStore doGetPreferenceStore()
     {
         return SigilCore.getDefault().getPreferenceStore();
     }
 
-
     @Override
     public boolean performOk()
     {
-        getPreferenceStore().setValue( SigilCore.DEFAULT_VERSION_LOWER_BOUND, lowerBoundRule.name() );
-        getPreferenceStore().setValue( SigilCore.DEFAULT_VERSION_UPPER_BOUND, upperBoundRule.name() );
+        getPreferenceStore().setValue(SigilCore.DEFAULT_VERSION_LOWER_BOUND,
+            lowerBoundRule.name());
+        getPreferenceStore().setValue(SigilCore.DEFAULT_VERSION_UPPER_BOUND,
+            upperBoundRule.name());
 
         return true;
     }
 
-
     @Override
     protected void performDefaults()
     {
         super.performDefaults();
-        loadPreferences( true );
+        loadPreferences(true);
         updateRadioButtons();
         updateCalculatedRange();
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/installs/OSGiInstallsPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/installs/OSGiInstallsPreferencePage.java
index 2770b54..14dbe83 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/installs/OSGiInstallsPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/installs/OSGiInstallsPreferencePage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.installs;
 
-
 import java.util.HashMap;
 import java.util.UUID;
 
@@ -53,7 +52,6 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
-
 public class OSGiInstallsPreferencePage extends ProjectDependentPreferencesPage implements IWorkbenchPreferencePage
 {
 
@@ -63,19 +61,17 @@
         private String location;
         private IOSGiInstallType type;
 
-
-        private Install( String id, String location )
+        private Install(String id, String location)
         {
             this.id = id;
             this.location = location;
         }
 
-
         private IOSGiInstallType getType()
         {
-            if ( type == null )
+            if (type == null)
             {
-                type = SigilCore.getInstallManager().findInstallType( location );
+                type = SigilCore.getInstallManager().findInstallType(location);
             }
             return type;
         }
@@ -85,24 +81,21 @@
     private CheckboxTableViewer viewer;
     private boolean changed;
 
-
     public OSGiInstallsPreferencePage()
     {
-        super( "OSGi Installs" );
+        super("OSGi Installs");
     }
 
-
-    public void init( IWorkbench workbench )
+    public void init(IWorkbench workbench)
     {
     }
 
-
     @Override
-    protected Control createContents( Composite parent )
+    protected Control createContents(Composite parent)
     {
-        Composite control = new Composite( parent, SWT.NONE );
+        Composite control = new Composite(parent, SWT.NONE);
 
-        buildComponents( control );
+        buildComponents(control);
 
         load();
 
@@ -111,79 +104,77 @@
         return control;
     }
 
-
     @Override
     protected boolean isDirty()
     {
         return changed;
     }
 
-
-    private void buildComponents( Composite control )
+    private void buildComponents(Composite control)
     {
-        new Label( control, SWT.NONE ).setText( "Installs:" );
-        new Label( control, SWT.NONE ); // padding
+        new Label(control, SWT.NONE).setText("Installs:");
+        new Label(control, SWT.NONE); // padding
 
-        Table table = new Table( control, SWT.CHECK | SWT.SINGLE | SWT.BORDER );
+        Table table = new Table(control, SWT.CHECK | SWT.SINGLE | SWT.BORDER);
 
-        Button add = new Button( control, SWT.PUSH );
-        add.setText( "Add" );
-        add.addSelectionListener( new SelectionAdapter()
+        Button add = new Button(control, SWT.PUSH);
+        add.setText("Add");
+        add.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 add();
             }
-        } );
+        });
 
-        final Button remove = new Button( control, SWT.PUSH );
-        remove.setEnabled( false );
-        remove.setText( "Remove" );
-        remove.addSelectionListener( new SelectionAdapter()
+        final Button remove = new Button(control, SWT.PUSH);
+        remove.setEnabled(false);
+        remove.setText("Remove");
+        remove.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 remove();
             }
-        } );
+        });
 
         // viewers
-        viewer = new CheckboxTableViewer( table );
-        viewer.setContentProvider( new DefaultTableProvider()
+        viewer = new CheckboxTableViewer(table);
+        viewer.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
+        });
 
-        viewer.setLabelProvider( new LabelProvider()
+        viewer.setLabelProvider(new LabelProvider()
         {
             @Override
-            public String getText( Object element )
+            public String getText(Object element)
             {
-                Install i = ( Install ) element;
+                Install i = (Install) element;
                 IOSGiInstallType type = i.getType();
-                if ( type == null )
+                if (type == null)
                 {
                     return "<invalid> [" + i.location + "]";
                 }
                 else
                 {
-                    return type.getName() + " " + type.getVersion() + " [" + i.location + "]";
+                    return type.getName() + " " + type.getVersion() + " [" + i.location
+                        + "]";
                 }
             }
 
-
             @Override
-            public Image getImage( Object element )
+            public Image getImage(Object element)
             {
-                Install i = ( Install ) element;
+                Install i = (Install) element;
                 IOSGiInstallType type = i.getType();
 
-                if ( type == null )
+                if (type == null)
                 {
                     return null;
                 }
@@ -192,139 +183,134 @@
                     return type.getIcon();
                 }
             }
-        } );
+        });
 
-        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        viewer.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
                 boolean enabled = !event.getSelection().isEmpty();
-                remove.setEnabled( enabled );
+                remove.setEnabled(enabled);
             }
-        } );
+        });
 
-        viewer.addCheckStateListener( new ICheckStateListener()
+        viewer.addCheckStateListener(new ICheckStateListener()
         {
-            public void checkStateChanged( CheckStateChangedEvent event )
+            public void checkStateChanged(CheckStateChangedEvent event)
             {
-                if ( event.getChecked() )
+                if (event.getChecked())
                 {
                     changed = true;
                 }
-                viewer.setCheckedElements( new Object[]
-                    { event.getElement() } );
+                viewer.setCheckedElements(new Object[] { event.getElement() });
             }
-        } );
+        });
 
-        viewer.setInput( installs.values() );
+        viewer.setInput(installs.values());
 
         // layout
-        control.setLayout( new GridLayout( 2, false ) );
-        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 ) );
-        add.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
-        remove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+        control.setLayout(new GridLayout(2, false));
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
+        add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
     }
 
-
     private void load()
     {
-        String pref = getPreferenceStore().getString( SigilCore.OSGI_INSTALLS );
-        if ( pref != null && pref.length() > 0 )
+        String pref = getPreferenceStore().getString(SigilCore.OSGI_INSTALLS);
+        if (pref != null && pref.length() > 0)
         {
-            for ( String id : pref.split( "," ) )
+            for (String id : pref.split(","))
             {
-                String loc = getPreferenceStore().getString( SigilCore.OSGI_INSTALL_PREFIX + id );
-                installs.put( id, new Install( id, loc ) );
+                String loc = getPreferenceStore().getString(
+                    SigilCore.OSGI_INSTALL_PREFIX + id);
+                installs.put(id, new Install(id, loc));
             }
         }
 
         viewer.refresh();
 
-        if ( !installs.isEmpty() )
+        if (!installs.isEmpty())
         {
-            String defId = getPreferenceStore().getString( SigilCore.OSGI_DEFAULT_INSTALL_ID );
-            if ( defId == null || defId.trim().length() == 0 )
+            String defId = getPreferenceStore().getString(
+                SigilCore.OSGI_DEFAULT_INSTALL_ID);
+            if (defId == null || defId.trim().length() == 0)
             {
-                viewer.setCheckedElements( new Object[]
-                    { installs.values().iterator().next() } );
+                viewer.setCheckedElements(new Object[] { installs.values().iterator().next() });
             }
             else
             {
-                viewer.setCheckedElements( new Object[]
-                    { installs.get( defId ) } );
+                viewer.setCheckedElements(new Object[] { installs.get(defId) });
             }
         }
     }
 
-
     protected void doSave()
     {
         // zero out old configs
-        String pref = getPreferenceStore().getString( SigilCore.OSGI_INSTALLS );
-        if ( pref != null && pref.length() > 0 )
+        String pref = getPreferenceStore().getString(SigilCore.OSGI_INSTALLS);
+        if (pref != null && pref.length() > 0)
         {
-            for ( String id : pref.split( "," ) )
+            for (String id : pref.split(","))
             {
-                getPreferenceStore().setToDefault( SigilCore.OSGI_INSTALL_PREFIX + id );
+                getPreferenceStore().setToDefault(SigilCore.OSGI_INSTALL_PREFIX + id);
             }
         }
 
         // store new configs
-        if ( installs.isEmpty() )
+        if (installs.isEmpty())
         {
-            getPreferenceStore().setToDefault( SigilCore.OSGI_INSTALLS );
-            getPreferenceStore().setToDefault( SigilCore.OSGI_DEFAULT_INSTALL_ID );
+            getPreferenceStore().setToDefault(SigilCore.OSGI_INSTALLS);
+            getPreferenceStore().setToDefault(SigilCore.OSGI_DEFAULT_INSTALL_ID);
         }
         else
         {
             StringBuffer buf = new StringBuffer();
-            for ( Install i : installs.values() )
+            for (Install i : installs.values())
             {
-                if ( buf.length() > 0 )
+                if (buf.length() > 0)
                 {
-                    buf.append( "," );
+                    buf.append(",");
                 }
-                buf.append( i.id );
-                getPreferenceStore().setValue( SigilCore.OSGI_INSTALL_PREFIX + i.id, i.location );
+                buf.append(i.id);
+                getPreferenceStore().setValue(SigilCore.OSGI_INSTALL_PREFIX + i.id,
+                    i.location);
             }
 
-            getPreferenceStore().setValue( SigilCore.OSGI_INSTALLS, buf.toString() );
-            Install def = ( Install ) viewer.getCheckedElements()[0];
-            getPreferenceStore().setValue( SigilCore.OSGI_DEFAULT_INSTALL_ID, def.id );
+            getPreferenceStore().setValue(SigilCore.OSGI_INSTALLS, buf.toString());
+            Install def = (Install) viewer.getCheckedElements()[0];
+            getPreferenceStore().setValue(SigilCore.OSGI_DEFAULT_INSTALL_ID, def.id);
         }
         changed = false;
     }
 
-
     private boolean isOK()
     {
         return installs.isEmpty() || viewer.getCheckedElements().length > 0;
     }
 
-
     private void add()
     {
         Shell shell = SigilUI.getActiveWorkbenchShell();
-        DirectoryDialog dialog = new DirectoryDialog( shell );
+        DirectoryDialog dialog = new DirectoryDialog(shell);
         String dir = dialog.open();
-        if ( dir != null )
+        if (dir != null)
         {
-            Install install = new Install( UUID.randomUUID().toString(), dir );
-            if ( install.getType() == null )
+            Install install = new Install(UUID.randomUUID().toString(), dir);
+            if (install.getType() == null)
             {
-                MessageDialog.openError( shell, "Error", "Invalid OSGi install directory" );
+                MessageDialog.openError(shell, "Error", "Invalid OSGi install directory");
             }
             else
             {
                 boolean empty = installs.isEmpty();
 
-                installs.put( install.id, install );
+                installs.put(install.id, install);
                 viewer.refresh();
 
-                if ( empty )
+                if (empty)
                 {
-                    viewer.setCheckedElements( new Object[]
-                        { install } );
+                    viewer.setCheckedElements(new Object[] { install });
                 }
 
                 checkValid();
@@ -333,39 +319,35 @@
         }
     }
 
-
     private void checkValid()
     {
-        if ( isOK() )
+        if (isOK())
         {
-            setErrorMessage( null );
-            setValid( true );
+            setErrorMessage(null);
+            setValid(true);
         }
         else
         {
-            setErrorMessage( "Missing default OSGi install" );
-            setValid( false );
+            setErrorMessage("Missing default OSGi install");
+            setValid(false);
         }
     }
 
-
     private void remove()
     {
-        IStructuredSelection sel = ( IStructuredSelection ) viewer.getSelection();
-        Install i = ( Install ) sel.getFirstElement();
-        boolean def = viewer.getChecked( i );
-        installs.remove( i.id );
+        IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
+        Install i = (Install) sel.getFirstElement();
+        boolean def = viewer.getChecked(i);
+        installs.remove(i.id);
         viewer.refresh();
-        if ( def && installs.size() > 0 )
+        if (def && installs.size() > 0)
         {
-            viewer.setCheckedElements( new Object[]
-                { installs.values().iterator().next() } );
+            viewer.setCheckedElements(new Object[] { installs.values().iterator().next() });
         }
         checkValid();
         changed = true;
     }
 
-
     @Override
     protected IPreferenceStore doGetPreferenceStore()
     {
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/project/ProjectPropertyPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/project/ProjectPropertyPage.java
index 967b3fc..ce23d9b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/project/ProjectPropertyPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/project/ProjectPropertyPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.project;
 
-
 import java.util.concurrent.Callable;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
@@ -49,7 +48,6 @@
 import org.eclipse.ui.dialogs.PropertyPage;
 import org.osgi.service.prefs.BackingStoreException;
 
-
 public class ProjectPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
 {
 
@@ -58,170 +56,163 @@
     private Composite settings;
     private Button projectSpecificBtn;
 
-
     @Override
-    protected Control createContents( Composite parent )
+    protected Control createContents(Composite parent)
     {
-        final Composite control = new Composite( parent, SWT.NONE );
+        final Composite control = new Composite(parent, SWT.NONE);
 
-        projectSpecificBtn = new Button( control, SWT.CHECK );
-        projectSpecificBtn.setText( "Enable project specific settings" );
-        projectSpecificBtn.addSelectionListener( new SelectionAdapter()
+        projectSpecificBtn = new Button(control, SWT.CHECK);
+        projectSpecificBtn.setText("Enable project specific settings");
+        projectSpecificBtn.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                setProjectSpecific( !projectSpecific );
+                setProjectSpecific(!projectSpecific);
             }
-        } );
+        });
 
-        Label link = new Label( control, SWT.UNDERLINE_SINGLE );
-        link.addMouseListener( new MouseAdapter()
+        Label link = new Label(control, SWT.UNDERLINE_SINGLE);
+        link.addMouseListener(new MouseAdapter()
         {
             @Override
-            public void mouseDown( MouseEvent e )
+            public void mouseDown(MouseEvent e)
             {
-                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( null,
-                    SigilCore.REPOSITORIES_PREFERENCES_ID, null, null );
+                PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null,
+                    SigilCore.REPOSITORIES_PREFERENCES_ID, null, null);
                 dialog.open();
             }
-        } );
+        });
 
-        link.setText( "Configure workspace settings" );
+        link.setText("Configure workspace settings");
 
-        settings = new Composite( control, SWT.BORDER );
-        settings.setLayout( new GridLayout( 1, false ) );
-        createSettings( settings );
+        settings = new Composite(control, SWT.BORDER);
+        settings.setLayout(new GridLayout(1, false));
+        createSettings(settings);
 
-        setFonts( control );
+        setFonts(control);
 
         // layout
-        control.setLayout( new GridLayout( 2, false ) );
-        projectSpecificBtn.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        settings.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) );
+        control.setLayout(new GridLayout(2, false));
+        projectSpecificBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        settings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
 
         // load settings
         String currentSet = getCurrentSet();
 
-        if ( currentSet == null )
+        if (currentSet == null)
         {
-            setProjectSpecific( false );
+            setProjectSpecific(false);
         }
         else
         {
-            setView.setSelection( new StructuredSelection( currentSet ) );
-            setProjectSpecific( true );
+            setView.setSelection(new StructuredSelection(currentSet));
+            setProjectSpecific(true);
         }
 
         return control;
     }
 
-
-    private void setFonts( Composite control )
+    private void setFonts(Composite control)
     {
         Composite p = control.getParent();
-        for ( Control c : control.getChildren() )
+        for (Control c : control.getChildren())
         {
-            c.setFont( p.getFont() );
-            if ( c instanceof Composite )
+            c.setFont(p.getFont());
+            if (c instanceof Composite)
             {
-                setFonts( ( Composite ) c );
+                setFonts((Composite) c);
             }
         }
     }
 
-
-    private void setProjectSpecific( boolean projectSpecific )
+    private void setProjectSpecific(boolean projectSpecific)
     {
-        if ( this.projectSpecific != projectSpecific )
+        if (this.projectSpecific != projectSpecific)
         {
             this.projectSpecific = projectSpecific;
-            settings.setEnabled( projectSpecific );
-            for ( Control c : settings.getChildren() )
+            settings.setEnabled(projectSpecific);
+            for (Control c : settings.getChildren())
             {
-                c.setEnabled( projectSpecific );
+                c.setEnabled(projectSpecific);
             }
-            projectSpecificBtn.setSelection( projectSpecific );
+            projectSpecificBtn.setSelection(projectSpecific);
         }
     }
 
-
-    private void createSettings( Composite parent )
+    private void createSettings(Composite parent)
     {
-        Composite control = new Composite( parent, SWT.NONE );
+        Composite control = new Composite(parent, SWT.NONE);
 
-        new Label( control, SWT.NONE ).setText( "Repository Set:" );
-        Combo combo = new Combo( control, SWT.SINGLE );
+        new Label(control, SWT.NONE).setText("Repository Set:");
+        Combo combo = new Combo(control, SWT.SINGLE);
 
-        setView = new ComboViewer( combo );
-        setView.setContentProvider( new DefaultTableProvider()
+        setView = new ComboViewer(combo);
+        setView.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
+        });
 
-        setView.setInput( SigilCore.getRepositoryConfiguration().loadRepositorySets().keySet() );
+        setView.setInput(SigilCore.getRepositoryConfiguration().loadRepositorySets().keySet());
 
         // layout
-        control.setLayout( new GridLayout( 2, false ) );
+        control.setLayout(new GridLayout(2, false));
     }
 
-
     private String getCurrentSet()
     {
         try
         {
-            IProject p = ( IProject ) getElement().getAdapter( IProject.class );
-            ISigilProjectModel model = SigilCore.create( p );
-            return model.getPreferences().get( SigilCore.REPOSITORY_SET, null );
+            IProject p = (IProject) getElement().getAdapter(IProject.class);
+            ISigilProjectModel model = SigilCore.create(p);
+            return model.getPreferences().get(SigilCore.REPOSITORY_SET, null);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to read repository set", e );
+            SigilCore.error("Failed to read repository set", e);
             return null;
         }
     }
 
-
     @Override
     public boolean okToLeave()
     {
-        if ( projectSpecific )
+        if (projectSpecific)
         {
-            if ( setView.getSelection().isEmpty() )
+            if (setView.getSelection().isEmpty())
             {
-                setErrorMessage( "Must select a repository set" );
+                setErrorMessage("Must select a repository set");
                 return false;
             }
         }
-        setErrorMessage( null );
+        setErrorMessage(null);
         return true;
     }
 
-
     @Override
     public boolean performOk()
     {
-        return ProjectUtils.runTaskWithRebuildCheck( new Callable<Boolean>()
+        return ProjectUtils.runTaskWithRebuildCheck(new Callable<Boolean>()
         {
             public Boolean call() throws CoreException, BackingStoreException
             {
                 String set = null;
-                if ( projectSpecific )
+                if (projectSpecific)
                 {
-                    set = ( String ) ( ( IStructuredSelection ) setView.getSelection() ).getFirstElement();
+                    set = (String) ((IStructuredSelection) setView.getSelection()).getFirstElement();
                 }
 
-                IProject p = ( IProject ) getElement().getAdapter( IProject.class );
-                ISigilProjectModel model = SigilCore.create( p );
-                model.getPreferences().put( SigilCore.REPOSITORY_SET, set );
+                IProject p = (IProject) getElement().getAdapter(IProject.class);
+                ISigilProjectModel model = SigilCore.create(p);
+                model.getPreferences().put(SigilCore.REPOSITORY_SET, set);
                 model.getPreferences().flush();
                 return true;
             }
 
-        }, getShell() );
+        }, getShell());
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/NewRepositoryWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/NewRepositoryWizard.java
index c10d84c..0e5935e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/NewRepositoryWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/NewRepositoryWizard.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
 import org.eclipse.jface.wizard.Wizard;
 
-
 public class NewRepositoryWizard extends Wizard
 {
 
@@ -31,13 +29,11 @@
 
     private RepositoryTypeSelectionPage page = new RepositoryTypeSelectionPage();
 
-
     public void addPages()
     {
-        addPage( page );
+        addPage(page);
     }
 
-
     @Override
     public boolean performFinish()
     {
@@ -45,14 +41,12 @@
         return true;
     }
 
-
     @Override
     public boolean needsPreviousAndNextButtons()
     {
         return true;
     }
 
-
     public IRepositoryModel getRepository()
     {
         return repository;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesPreferencePage.java
index a8f0bea..a1c3a0c 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesPreferencePage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryConfiguration;
 import org.apache.felix.sigil.eclipse.model.repository.IRepositorySet;
@@ -37,7 +36,6 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
-
 public class RepositoriesPreferencePage extends ProjectDependentPreferencesPage implements IWorkbenchPreferencePage
 {
 
@@ -45,89 +43,82 @@
     private RepositoriesView viewPage;
     private RepositorySetsView setPage;
 
-
     public RepositoriesPreferencePage()
     {
-        super( "Repository Preferences" );
+        super("Repository Preferences");
     }
 
-
     @Override
-    protected Control createContents( Composite parent )
+    protected Control createContents(Composite parent)
     {
-        Control control = initContents( parent );
+        Control control = initContents(parent);
         return control;
     }
 
-
     @Override
     protected IPreferenceStore doGetPreferenceStore()
     {
         return SigilCore.getDefault().getPreferenceStore();
     }
 
-
     protected void changed()
     {
         changed = true;
         updateApplyButton();
     }
 
-
-    private Control initContents( Composite parent )
+    private Control initContents(Composite parent)
     {
-        viewPage = new RepositoriesView( this );
-        setPage = new RepositorySetsView( this );
+        viewPage = new RepositoriesView(this);
+        setPage = new RepositorySetsView(this);
 
-        Composite control = new Composite( parent, SWT.NONE );
+        Composite control = new Composite(parent, SWT.NONE);
 
-        TabFolder folder = new TabFolder( control, SWT.TOP );
+        TabFolder folder = new TabFolder(control, SWT.TOP);
 
-        TabItem view = new TabItem( folder, SWT.NONE );
-        view.setText( "Repositories" );
-        view.setControl( viewPage.createContents( folder ) );
+        TabItem view = new TabItem(folder, SWT.NONE);
+        view.setText("Repositories");
+        view.setControl(viewPage.createContents(folder));
 
-        TabItem sets = new TabItem( folder, SWT.NONE );
-        sets.setText( "Sets" );
-        sets.setControl( setPage.createContents( folder ) );
+        TabItem sets = new TabItem(folder, SWT.NONE);
+        sets.setText("Sets");
+        sets.setControl(setPage.createContents(folder));
 
-        control.setLayout( new GridLayout( 1, true ) );
-        folder.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+        control.setLayout(new GridLayout(1, true));
+        folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
         return control;
     }
 
-
-    public void init( IWorkbench workbench )
+    public void init(IWorkbench workbench)
     {
         // TODO Auto-generated method stub
 
     }
 
-
     @Override
     protected void doSave()
     {
         try
         {
             IRepositoryConfiguration config = SigilCore.getRepositoryConfiguration();
-            config.saveRepositories( viewPage.getRepositories() );
-            config.saveRepositorySets( setPage.getSets() );
-            IRepositorySet defaultSet = new RepositorySet( setPage.getDefaultRepositories() );
-            config.setDefaultRepositorySet( defaultSet );
+            config.saveRepositories(viewPage.getRepositories());
+            config.saveRepositorySets(setPage.getSets());
+            IRepositorySet defaultSet = new RepositorySet(
+                setPage.getDefaultRepositories());
+            config.setDefaultRepositorySet(defaultSet);
 
-            setErrorMessage( null );
-            getApplyButton().setEnabled( false );
+            setErrorMessage(null);
+            getApplyButton().setEnabled(false);
             changed = false;
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            setErrorMessage( "Failed to save repositories:" + e.getStatus().getMessage() );
-            SigilCore.error( "Failed to save repositories", e );
+            setErrorMessage("Failed to save repositories:" + e.getStatus().getMessage());
+            SigilCore.error("Failed to save repositories", e);
         }
     }
 
-
     @Override
     protected boolean isDirty()
     {
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesView.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesView.java
index 136052d..fab0a60 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesView.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesView.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -50,7 +49,6 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
 
-
 public class RepositoriesView
 {
     private final RepositoriesPreferencePage page;
@@ -59,260 +57,247 @@
 
     private TableViewer repositoryView;
 
-
-    public RepositoriesView( RepositoriesPreferencePage page )
+    public RepositoriesView(RepositoriesPreferencePage page)
     {
         this.page = page;
     }
 
-
-    public Control createContents( Composite parent )
+    public Control createContents(Composite parent)
     {
         // Create Controls
-        Composite composite = new Composite( parent, SWT.NONE );
+        Composite composite = new Composite(parent, SWT.NONE);
 
-        Table table = new Table( composite, SWT.MULTI | SWT.BORDER );
+        Table table = new Table(composite, SWT.MULTI | SWT.BORDER);
 
         // Table Viewer Setup
-        repositoryView = new TableViewer( table );
-        repositoryView.setLabelProvider( new LabelProvider()
+        repositoryView = new TableViewer(table);
+        repositoryView.setLabelProvider(new LabelProvider()
         {
             @Override
-            public String getText( Object element )
+            public String getText(Object element)
             {
-                IRepositoryModel rep = ( IRepositoryModel ) element;
+                IRepositoryModel rep = (IRepositoryModel) element;
                 return rep.getName();
             }
 
-
             @Override
-            public Image getImage( Object element )
+            public Image getImage(Object element)
             {
-                IRepositoryModel rep = ( IRepositoryModel ) element;
+                IRepositoryModel rep = (IRepositoryModel) element;
                 return rep.getType().getIcon();
             }
-        } );
+        });
 
-        repositoryView.setContentProvider( new DefaultTableProvider()
+        repositoryView.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
+        });
 
         // Layout
-        composite.setLayout( new GridLayout( 2, false ) );
-        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 6 ) );
+        composite.setLayout(new GridLayout(2, false));
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6));
 
-        createButtons( composite, repositoryView );
+        createButtons(composite, repositoryView);
 
         repositories = SigilCore.getRepositoryConfiguration().loadRepositories();
-        repositoryView.setInput( repositories );
+        repositoryView.setInput(repositories);
 
         return composite;
     }
 
-
-    private void createButtons( final Composite composite, final TableViewer repositoryView )
+    private void createButtons(final Composite composite, final TableViewer repositoryView)
     {
-        final Button add = new Button( composite, SWT.PUSH );
-        add.setText( "Add..." );
-        add.setEnabled( true );
+        final Button add = new Button(composite, SWT.PUSH);
+        add.setText("Add...");
+        add.setEnabled(true);
 
-        final Button edit = new Button( composite, SWT.PUSH );
-        edit.setText( "Edit..." );
-        edit.setEnabled( false );
+        final Button edit = new Button(composite, SWT.PUSH);
+        edit.setText("Edit...");
+        edit.setEnabled(false);
 
-        final Button remove = new Button( composite, SWT.PUSH );
-        remove.setText( "Remove" );
-        remove.setEnabled( false );
+        final Button remove = new Button(composite, SWT.PUSH);
+        remove.setText("Remove");
+        remove.setEnabled(false);
 
-        final Button refresh = new Button( composite, SWT.PUSH );
-        refresh.setText( "Refresh" );
-        refresh.setEnabled( false );
+        final Button refresh = new Button(composite, SWT.PUSH);
+        refresh.setText("Refresh");
+        refresh.setEnabled(false);
 
         // Listeners
-        add.addSelectionListener( new SelectionAdapter()
+        add.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                add( composite );
+                add(composite);
             }
-        } );
+        });
 
-        edit.addSelectionListener( new SelectionAdapter()
+        edit.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                IStructuredSelection sel = ( IStructuredSelection ) repositoryView.getSelection();
-                edit( composite, sel );
+                IStructuredSelection sel = (IStructuredSelection) repositoryView.getSelection();
+                edit(composite, sel);
             }
-        } );
+        });
 
-        remove.addSelectionListener( new SelectionAdapter()
+        remove.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                IStructuredSelection sel = ( IStructuredSelection ) repositoryView.getSelection();
-                remove( sel );
+                IStructuredSelection sel = (IStructuredSelection) repositoryView.getSelection();
+                remove(sel);
             }
-        } );
+        });
 
-        refresh.addSelectionListener( new SelectionAdapter()
+        refresh.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                IStructuredSelection sel = ( IStructuredSelection ) repositoryView.getSelection();
-                refresh( composite, sel );
+                IStructuredSelection sel = (IStructuredSelection) repositoryView.getSelection();
+                refresh(composite, sel);
             }
-        } );
+        });
 
-        repositoryView.addSelectionChangedListener( new ISelectionChangedListener()
+        repositoryView.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
                 boolean selected = !event.getSelection().isEmpty();
-                if ( selected )
+                if (selected)
                 {
-                    refresh.setEnabled( true );
+                    refresh.setEnabled(true);
 
-                    IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
+                    IStructuredSelection sel = (IStructuredSelection) event.getSelection();
 
-                    checkEditEnabled( edit, sel );
-                    checkRemoveEnabled( remove, sel );
+                    checkEditEnabled(edit, sel);
+                    checkRemoveEnabled(remove, sel);
                 }
                 else
                 {
-                    refresh.setEnabled( false );
-                    edit.setEnabled( false );
-                    remove.setEnabled( false );
+                    refresh.setEnabled(false);
+                    edit.setEnabled(false);
+                    remove.setEnabled(false);
                 }
             }
-        } );
+        });
 
-        add.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
-        edit.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
-        remove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+        add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        edit.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
     }
 
-
     @SuppressWarnings("unchecked")
-    private void checkRemoveEnabled( Button button, IStructuredSelection sel )
+    private void checkRemoveEnabled(Button button, IStructuredSelection sel)
     {
         boolean alldynamic = true;
-        for ( Iterator i = sel.iterator(); i.hasNext(); )
+        for (Iterator i = sel.iterator(); i.hasNext();)
         {
-            IRepositoryModel model = ( IRepositoryModel ) i.next();
-            if ( !model.getType().isDynamic() )
+            IRepositoryModel model = (IRepositoryModel) i.next();
+            if (!model.getType().isDynamic())
             {
                 alldynamic = false;
                 break;
             }
         }
-        button.setEnabled( alldynamic );
+        button.setEnabled(alldynamic);
     }
 
-
-    private void checkEditEnabled( Button edit, IStructuredSelection sel )
+    private void checkEditEnabled(Button edit, IStructuredSelection sel)
     {
-        if ( sel.size() == 1 )
+        if (sel.size() == 1)
         {
-            IRepositoryModel element = ( IRepositoryModel ) sel.getFirstElement();
-            if ( WizardHelper.hasWizard( element.getType() ) )
+            IRepositoryModel element = (IRepositoryModel) sel.getFirstElement();
+            if (WizardHelper.hasWizard(element.getType()))
             {
-                edit.setEnabled( true );
+                edit.setEnabled(true);
             }
             else
             {
-                edit.setEnabled( false );
+                edit.setEnabled(false);
             }
         }
         else
         {
-            edit.setEnabled( false );
+            edit.setEnabled(false);
         }
     }
 
-
     @SuppressWarnings("unchecked")
-    protected void refresh( Control parent, IStructuredSelection sel )
+    protected void refresh(Control parent, IStructuredSelection sel)
     {
-        ArrayList<IRepositoryModel> models = new ArrayList<IRepositoryModel>( sel.size() );
+        ArrayList<IRepositoryModel> models = new ArrayList<IRepositoryModel>(sel.size());
 
-        for ( Iterator i = sel.iterator(); i.hasNext(); )
+        for (Iterator i = sel.iterator(); i.hasNext();)
         {
-            IRepositoryModel model = ( IRepositoryModel ) i.next();
-            models.add( model );
+            IRepositoryModel model = (IRepositoryModel) i.next();
+            models.add(model);
         }
 
-        new RefreshRepositoryAction( models.toArray( new IRepositoryModel[models.size()] ) ).run();
+        new RefreshRepositoryAction(models.toArray(new IRepositoryModel[models.size()])).run();
     }
 
-
-    private void add( Control parent )
+    private void add(Control parent)
     {
         NewRepositoryWizard wizard = new NewRepositoryWizard();
-        WizardDialog dialog = new WizardDialog( getShell( parent ), wizard );
-        if ( dialog.open() == Window.OK )
+        WizardDialog dialog = new WizardDialog(getShell(parent), wizard);
+        if (dialog.open() == Window.OK)
         {
-            repositories.add( wizard.getRepository() );
+            repositories.add(wizard.getRepository());
             updated();
         }
     }
 
-
-    private void edit( Control parent, IStructuredSelection sel )
+    private void edit(Control parent, IStructuredSelection sel)
     {
-        IRepositoryModel model = ( IRepositoryModel ) sel.getFirstElement();
+        IRepositoryModel model = (IRepositoryModel) sel.getFirstElement();
         try
         {
-            RepositoryWizard wizard = WizardHelper.loadWizard( model.getType() );
-            wizard.init( model );
-            WizardDialog dialog = new WizardDialog( getShell( parent ), wizard );
-            if ( dialog.open() == Window.OK )
+            RepositoryWizard wizard = WizardHelper.loadWizard(model.getType());
+            wizard.init(model);
+            WizardDialog dialog = new WizardDialog(getShell(parent), wizard);
+            if (dialog.open() == Window.OK)
             {
                 updated();
             }
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to load wizard", e );
-            MessageDialog
-                .openError( getShell( parent ), "Error", "Failed to load wizard:" + e.getStatus().getMessage() );
+            SigilCore.error("Failed to load wizard", e);
+            MessageDialog.openError(getShell(parent), "Error", "Failed to load wizard:"
+                + e.getStatus().getMessage());
         }
     }
 
-
-    private Shell getShell( Control parent )
+    private Shell getShell(Control parent)
     {
         return parent.getShell();
     }
 
-
     @SuppressWarnings("unchecked")
-    private void remove( IStructuredSelection sel )
+    private void remove(IStructuredSelection sel)
     {
         boolean change = false;
-        for ( Iterator i = sel.iterator(); i.hasNext(); )
+        for (Iterator i = sel.iterator(); i.hasNext();)
         {
-            change = repositories.remove( i.next() );
+            change = repositories.remove(i.next());
         }
 
-        if ( change )
+        if (change)
         {
             updated();
         }
     }
 
-
     private void updated()
     {
         repositoryView.refresh();
         page.changed();
     }
 
-
     public List<IRepositoryModel> getRepositories()
     {
         return repositories;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetDialog.java
index 6ddc791..a2e08a4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -50,7 +49,6 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 
-
 public class RepositorySetDialog extends TitleAreaDialog
 {
 
@@ -65,101 +63,94 @@
 
     private String newName;
 
-
-    public RepositorySetDialog( Shell shell, Set<String> set )
+    public RepositorySetDialog(Shell shell, Set<String> set)
     {
-        this( shell, null, true, set );
+        this(shell, null, true, set);
     }
 
-
-    public RepositorySetDialog( Shell parent, RepositoryViewData data, boolean nameEditable, Set<String> set )
+    public RepositorySetDialog(Shell parent, RepositoryViewData data, boolean nameEditable, Set<String> set)
     {
-        super( parent );
+        super(parent);
         this.set = set;
         this.setName = data == null ? "" : data.getName();
-        this.repositories = data == null ? new ArrayList<IRepositoryModel>() : new ArrayList<IRepositoryModel>( Arrays
-            .asList( data.getRepositories() ) );
+        this.repositories = data == null ? new ArrayList<IRepositoryModel>()
+            : new ArrayList<IRepositoryModel>(Arrays.asList(data.getRepositories()));
         this.nameEditable = nameEditable;
     }
 
-
     @Override
-    protected Control createDialogArea( Composite parent )
+    protected Control createDialogArea(Composite parent)
     {
-        Composite area = ( Composite ) super.createDialogArea( parent );
-        createControl( area );
+        Composite area = (Composite) super.createDialogArea(parent);
+        createControl(area);
         return area;
     }
 
-
-    public void createControl( Composite parent )
+    public void createControl(Composite parent)
     {
         // controls
-        Composite body = new Composite( parent, SWT.NONE );
-        body.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        Composite body = new Composite(parent, SWT.NONE);
+        body.setLayoutData(new GridData(GridData.FILL_BOTH));
 
-        if ( nameEditable )
+        if (nameEditable)
         {
-            new Label( body, SWT.NONE ).setText( "Name" );
+            new Label(body, SWT.NONE).setText("Name");
 
-            nameTxt = new Text( body, SWT.BORDER );
+            nameTxt = new Text(body, SWT.BORDER);
 
-            nameTxt.setText( setName );
+            nameTxt.setText(setName);
 
-            nameTxt.addKeyListener( new KeyAdapter()
+            nameTxt.addKeyListener(new KeyAdapter()
             {
                 @Override
-                public void keyReleased( KeyEvent e )
+                public void keyReleased(KeyEvent e)
                 {
                     checkComplete();
                 }
-            } );
+            });
         }
 
-        Composite table = new Composite( body, SWT.NONE );
-        table.setLayout( new GridLayout( 2, false ) );
-        createTable( table );
+        Composite table = new Composite(body, SWT.NONE);
+        table.setLayout(new GridLayout(2, false));
+        createTable(table);
 
         // layout
-        body.setLayout( new GridLayout( 2, false ) );
-        if ( nameEditable )
+        body.setLayout(new GridLayout(2, false));
+        if (nameEditable)
         {
-            nameTxt.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+            nameTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
         }
-        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) );
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
     }
 
-
     public RepositoryViewData getData()
     {
         String name = nameEditable ? newName : setName;
-        IRepositoryModel[] reps = repositories.toArray( new IRepositoryModel[repositories.size()] );
-        return new RepositoryViewData( name, reps );
+        IRepositoryModel[] reps = repositories.toArray(new IRepositoryModel[repositories.size()]);
+        return new RepositoryViewData(name, reps);
     }
 
-
     private void checkComplete()
     {
-        if ( nameEditable )
+        if (nameEditable)
         {
             String name = nameTxt.getText();
-            if ( !name.equals( setName ) && set.contains( name ) )
+            if (!name.equals(setName) && set.contains(name))
             {
-                setErrorMessage( "Set " + name + " already exists" );
-                Button b = getButton( IDialogConstants.OK_ID );
-                b.setEnabled( false );
+                setErrorMessage("Set " + name + " already exists");
+                Button b = getButton(IDialogConstants.OK_ID);
+                b.setEnabled(false);
             }
         }
-        setErrorMessage( null );
-        Button b = getButton( IDialogConstants.OK_ID );
-        b.setEnabled( true );
+        setErrorMessage(null);
+        Button b = getButton(IDialogConstants.OK_ID);
+        b.setEnabled(true);
     }
 
-
     @Override
     protected void okPressed()
     {
-        if ( nameEditable )
+        if (nameEditable)
         {
             newName = nameTxt.getText();
         }
@@ -167,150 +158,140 @@
         super.okPressed();
     }
 
-
-    private void createTable( Composite body )
+    private void createTable(Composite body)
     {
-        createViewer( body );
+        createViewer(body);
 
-        Composite btns = new Composite( body, SWT.NONE );
-        btns.setLayout( new GridLayout( 1, true ) );
+        Composite btns = new Composite(body, SWT.NONE);
+        btns.setLayout(new GridLayout(1, true));
 
-        createButtons( btns );
+        createButtons(btns);
 
         // layout
-        viewer.getTable().setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
-        btns.setLayoutData( new GridData( SWT.RIGHT, SWT.TOP, false, false ) );
+        viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        btns.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
     }
 
-
-    private void createButtons( Composite parent )
+    private void createButtons(Composite parent)
     {
-        upBtn = new Button( parent, SWT.PUSH );
-        upBtn.setText( "Up" );
-        upBtn.addSelectionListener( new SelectionAdapter()
+        upBtn = new Button(parent, SWT.PUSH);
+        upBtn.setText("Up");
+        upBtn.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 up();
             }
-        } );
+        });
 
-        downBtn = new Button( parent, SWT.PUSH );
-        downBtn.setText( "Down" );
-        downBtn.addSelectionListener( new SelectionAdapter()
+        downBtn = new Button(parent, SWT.PUSH);
+        downBtn.setText("Down");
+        downBtn.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 down();
             }
-        } );
+        });
 
-        setUpDownEnabled( false );
+        setUpDownEnabled(false);
     }
 
-
     private void up()
     {
-        IRepositoryModel model = ( IRepositoryModel ) ( ( StructuredSelection ) viewer.getSelection() )
-            .getFirstElement();
-        int i = repositories.indexOf( model );
-        if ( i > 0 )
+        IRepositoryModel model = (IRepositoryModel) ((StructuredSelection) viewer.getSelection()).getFirstElement();
+        int i = repositories.indexOf(model);
+        if (i > 0)
         {
-            repositories.remove( i );
-            repositories.add( i - 1, model );
+            repositories.remove(i);
+            repositories.add(i - 1, model);
             viewer.refresh();
         }
     }
 
-
     private void down()
     {
-        IRepositoryModel model = ( IRepositoryModel ) ( ( StructuredSelection ) viewer.getSelection() )
-            .getFirstElement();
-        int i = repositories.indexOf( model );
-        if ( i < repositories.size() - 1 )
+        IRepositoryModel model = (IRepositoryModel) ((StructuredSelection) viewer.getSelection()).getFirstElement();
+        int i = repositories.indexOf(model);
+        if (i < repositories.size() - 1)
         {
-            repositories.remove( i );
-            repositories.add( i + 1, model );
+            repositories.remove(i);
+            repositories.add(i + 1, model);
             viewer.refresh();
         }
     }
 
-
-    private void createViewer( Composite parent )
+    private void createViewer(Composite parent)
     {
-        viewer = CheckboxTableViewer.newCheckList( parent, SWT.BORDER );
+        viewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
 
-        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        viewer.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
-                setUpDownEnabled( !viewer.getSelection().isEmpty() );
+                setUpDownEnabled(!viewer.getSelection().isEmpty());
             }
-        } );
+        });
 
-        viewer.setContentProvider( new DefaultTableProvider()
+        viewer.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
+        });
 
-        viewer.setLabelProvider( new DefaultLabelProvider()
+        viewer.setLabelProvider(new DefaultLabelProvider()
         {
-            public Image getImage( Object element )
+            public Image getImage(Object element)
             {
                 return null;
             }
 
-
-            public String getText( Object element )
+            public String getText(Object element)
             {
-                IRepositoryModel m = ( IRepositoryModel ) element;
+                IRepositoryModel m = (IRepositoryModel) element;
                 return m.getName();
             }
-        } );
+        });
 
-        viewer.setInput( repositories );
+        viewer.setInput(repositories);
 
-        for ( IRepositoryModel m : repositories )
+        for (IRepositoryModel m : repositories)
         {
-            viewer.setChecked( m, true );
+            viewer.setChecked(m, true);
         }
 
         List<IRepositoryModel> allRepositories = SigilCore.getRepositoryConfiguration().loadRepositories();
 
-        for ( IRepositoryModel m : allRepositories )
+        for (IRepositoryModel m : allRepositories)
         {
-            if ( !repositories.contains( m ) )
+            if (!repositories.contains(m))
             {
-                repositories.add( m );
+                repositories.add(m);
             }
         }
 
         viewer.refresh();
     }
 
-
-    private void setUpDownEnabled( boolean enabled )
+    private void setUpDownEnabled(boolean enabled)
     {
-        upBtn.setEnabled( enabled );
-        downBtn.setEnabled( enabled );
+        upBtn.setEnabled(enabled);
+        downBtn.setEnabled(enabled);
     }
 
-
     private List<IRepositoryModel> getRepositories()
     {
         ArrayList<IRepositoryModel> reps = new ArrayList<IRepositoryModel>();
 
-        for ( IRepositoryModel m : repositories )
+        for (IRepositoryModel m : repositories)
         {
-            if ( viewer.getChecked( m ) )
+            if (viewer.getChecked(m))
             {
-                reps.add( m );
+                reps.add(m);
             }
         }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetsView.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetsView.java
index a9b5401..bcb6248 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetsView.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetsView.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -49,7 +48,6 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
 
-
 public class RepositorySetsView
 {
     private static final String DEFAULT = "default";
@@ -62,218 +60,206 @@
 
     private RepositoryViewData defaultSet;
 
-
-    public RepositorySetsView( RepositoriesPreferencePage page )
+    public RepositorySetsView(RepositoriesPreferencePage page)
     {
         this.page = page;
     }
 
-
-    public Control createContents( Composite parent )
+    public Control createContents(Composite parent)
     {
         // Create Controls
-        Composite composite = new Composite( parent, SWT.NONE );
+        Composite composite = new Composite(parent, SWT.NONE);
 
-        Table table = new Table( composite, SWT.SINGLE | SWT.BORDER );
+        Table table = new Table(composite, SWT.SINGLE | SWT.BORDER);
 
         // Table Viewer Setup
-        setView = new TableViewer( table );
+        setView = new TableViewer(table);
 
-        setView.setContentProvider( new DefaultTableProvider()
+        setView.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
+        });
 
-        defaultSet = new RepositoryViewData( DEFAULT, SigilCore.getRepositoryConfiguration().getDefaultRepositorySet()
-            .getRepositories() );
+        defaultSet = new RepositoryViewData(
+            DEFAULT,
+            SigilCore.getRepositoryConfiguration().getDefaultRepositorySet().getRepositories());
 
-        sets.add( defaultSet );
+        sets.add(defaultSet);
 
-        for ( Map.Entry<String, IRepositorySet> e : SigilCore.getRepositoryConfiguration().loadRepositorySets()
-            .entrySet() )
+        for (Map.Entry<String, IRepositorySet> e : SigilCore.getRepositoryConfiguration().loadRepositorySets().entrySet())
         {
             IRepositorySet s = e.getValue();
-            sets.add( new RepositoryViewData( e.getKey(), s.getRepositories() ) );
+            sets.add(new RepositoryViewData(e.getKey(), s.getRepositories()));
         }
 
-        setView.setLabelProvider( new DefaultLabelProvider()
+        setView.setLabelProvider(new DefaultLabelProvider()
         {
-            public Image getImage( Object element )
+            public Image getImage(Object element)
             {
                 return null;
             }
 
-
-            public String getText( Object element )
+            public String getText(Object element)
             {
-                RepositoryViewData data = ( RepositoryViewData ) element;
+                RepositoryViewData data = (RepositoryViewData) element;
                 return data.getName();
             }
-        } );
+        });
 
-        setView.setInput( sets );
+        setView.setInput(sets);
 
         // Layout
-        composite.setLayout( new GridLayout( 2, false ) );
-        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 6 ) );
+        composite.setLayout(new GridLayout(2, false));
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6));
 
-        createButtons( composite );
+        createButtons(composite);
 
         return composite;
     }
 
-
-    private void createButtons( final Composite composite )
+    private void createButtons(final Composite composite)
     {
-        final Button add = new Button( composite, SWT.PUSH );
-        add.setText( "Add..." );
-        add.setEnabled( true );
+        final Button add = new Button(composite, SWT.PUSH);
+        add.setText("Add...");
+        add.setEnabled(true);
 
-        final Button edit = new Button( composite, SWT.PUSH );
-        edit.setText( "Edit..." );
-        edit.setEnabled( false );
+        final Button edit = new Button(composite, SWT.PUSH);
+        edit.setText("Edit...");
+        edit.setEnabled(false);
 
-        final Button remove = new Button( composite, SWT.PUSH );
-        remove.setText( "Remove" );
-        remove.setEnabled( false );
+        final Button remove = new Button(composite, SWT.PUSH);
+        remove.setText("Remove");
+        remove.setEnabled(false);
         // Listeners
-        add.addSelectionListener( new SelectionAdapter()
+        add.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                add( composite );
+                add(composite);
             }
-        } );
+        });
 
-        edit.addSelectionListener( new SelectionAdapter()
+        edit.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                IStructuredSelection sel = ( IStructuredSelection ) setView.getSelection();
-                edit( composite, sel );
+                IStructuredSelection sel = (IStructuredSelection) setView.getSelection();
+                edit(composite, sel);
             }
-        } );
+        });
 
-        remove.addSelectionListener( new SelectionAdapter()
+        remove.addSelectionListener(new SelectionAdapter()
         {
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
-                IStructuredSelection sel = ( IStructuredSelection ) setView.getSelection();
-                remove( sel );
+                IStructuredSelection sel = (IStructuredSelection) setView.getSelection();
+                remove(sel);
             }
-        } );
+        });
 
-        setView.addSelectionChangedListener( new ISelectionChangedListener()
+        setView.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
                 boolean enabled = !event.getSelection().isEmpty();
-                if ( enabled )
+                if (enabled)
                 {
-                    RepositoryViewData element = ( RepositoryViewData ) ( ( IStructuredSelection ) event.getSelection() )
-                        .getFirstElement();
-                    edit.setEnabled( true );
-                    remove.setEnabled( element != defaultSet );
+                    RepositoryViewData element = (RepositoryViewData) ((IStructuredSelection) event.getSelection()).getFirstElement();
+                    edit.setEnabled(true);
+                    remove.setEnabled(element != defaultSet);
                 }
                 else
                 {
-                    edit.setEnabled( false );
-                    remove.setEnabled( false );
+                    edit.setEnabled(false);
+                    remove.setEnabled(false);
                 }
             }
-        } );
+        });
 
-        add.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
-        edit.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
-        remove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+        add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        edit.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+        remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
     }
 
-
-    private void add( Control parent )
+    private void add(Control parent)
     {
-        RepositorySetDialog wizard = new RepositorySetDialog( getShell( parent ), getNames() );
-        if ( wizard.open() == Window.OK )
+        RepositorySetDialog wizard = new RepositorySetDialog(getShell(parent), getNames());
+        if (wizard.open() == Window.OK)
         {
-            sets.add( wizard.getData() );
+            sets.add(wizard.getData());
             updated();
         }
     }
 
-
-    private void edit( Control parent, IStructuredSelection sel )
+    private void edit(Control parent, IStructuredSelection sel)
     {
-        RepositoryViewData data = ( RepositoryViewData ) sel.getFirstElement();
-        RepositorySetDialog wizard = new RepositorySetDialog( getShell( parent ), data, data != defaultSet, getNames() );
-        if ( wizard.open() == Window.OK )
+        RepositoryViewData data = (RepositoryViewData) sel.getFirstElement();
+        RepositorySetDialog wizard = new RepositorySetDialog(getShell(parent), data,
+            data != defaultSet, getNames());
+        if (wizard.open() == Window.OK)
         {
-            if ( data != defaultSet )
+            if (data != defaultSet)
             {
-                data.setName( wizard.getData().getName() );
+                data.setName(wizard.getData().getName());
             }
-            data.setRepositories( wizard.getData().getRepositories() );
+            data.setRepositories(wizard.getData().getRepositories());
             updated();
         }
     }
 
-
     private Set<String> getNames()
     {
         HashSet<String> names = new HashSet<String>();
 
-        for ( RepositoryViewData view : sets )
+        for (RepositoryViewData view : sets)
         {
-            if ( view != defaultSet )
+            if (view != defaultSet)
             {
-                names.add( view.getName() );
+                names.add(view.getName());
             }
         }
 
         return names;
     }
 
-
-    private Shell getShell( Control parent )
+    private Shell getShell(Control parent)
     {
         return parent.getShell();
     }
 
-
-    private void remove( IStructuredSelection sel )
+    private void remove(IStructuredSelection sel)
     {
-        if ( sets.remove( sel.getFirstElement() ) )
+        if (sets.remove(sel.getFirstElement()))
         {
             updated();
         }
     }
 
-
     private void updated()
     {
         setView.refresh();
         page.changed();
     }
 
-
     public Map<String, IRepositorySet> getSets()
     {
         HashMap<String, IRepositorySet> ret = new HashMap<String, IRepositorySet>();
 
-        for ( RepositoryViewData data : sets )
+        for (RepositoryViewData data : sets)
         {
-            if ( data != defaultSet )
+            if (data != defaultSet)
             {
-                IRepositorySet set = new RepositorySet( data.getRepositories() );
-                ret.put( data.getName(), set );
+                IRepositorySet set = new RepositorySet(data.getRepositories());
+                ret.put(data.getName(), set);
             }
         }
 
         return ret;
     }
 
-
     public IRepositoryModel[] getDefaultRepositories()
     {
         return defaultSet.getRepositories();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryTypeSelectionPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryTypeSelectionPage.java
index 33b4ac5..309ab09 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryTypeSelectionPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryTypeSelectionPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import java.util.ArrayList;
 import java.util.Iterator;
 
@@ -42,7 +41,6 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Table;
 
-
 public class RepositoryTypeSelectionPage extends WizardSelectionPage implements IWizardPage
 {
 
@@ -51,97 +49,92 @@
     private TableViewer repositoryView;
     private IRepositoryModel repositoryElement;
 
-
     public RepositoryTypeSelectionPage()
     {
-        super( TITLE );
-        setTitle( TITLE );
+        super(TITLE);
+        setTitle(TITLE);
     }
 
-
-    public void createControl( Composite parent )
+    public void createControl(Composite parent)
     {
-        Composite control = new Composite( parent, SWT.NONE );
+        Composite control = new Composite(parent, SWT.NONE);
 
         // components
-        new Label( control, SWT.NONE ).setText( "Repositories" );
-        Table table = new Table( control, SWT.SINGLE | SWT.BORDER );
+        new Label(control, SWT.NONE).setText("Repositories");
+        Table table = new Table(control, SWT.SINGLE | SWT.BORDER);
 
         // layout
-        control.setLayout( new GridLayout( 1, true ) );
-        table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+        control.setLayout(new GridLayout(1, true));
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
         // view
-        repositoryView = new TableViewer( table );
-        repositoryView.setLabelProvider( new LabelProvider()
+        repositoryView = new TableViewer(table);
+        repositoryView.setLabelProvider(new LabelProvider()
         {
             @Override
-            public String getText( Object element )
+            public String getText(Object element)
             {
-                IRepositoryType rep = ( IRepositoryType ) element;
+                IRepositoryType rep = (IRepositoryType) element;
                 return rep.getType();
             }
 
-
             @Override
-            public Image getImage( Object element )
+            public Image getImage(Object element)
             {
-                IRepositoryType rep = ( IRepositoryType ) element;
+                IRepositoryType rep = (IRepositoryType) element;
                 return rep.getIcon();
             }
-        } );
+        });
 
-        repositoryView.setContentProvider( new DefaultTableProvider()
+        repositoryView.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
+        });
 
-        repositoryView.addSelectionChangedListener( new ISelectionChangedListener()
+        repositoryView.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
-                if ( !event.getSelection().isEmpty() )
+                if (!event.getSelection().isEmpty())
                 {
-                    IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
-                    IRepositoryType type = ( IRepositoryType ) sel.getFirstElement();
-                    repositoryElement = SigilCore.getRepositoryConfiguration().newRepositoryElement( type );
-                    selectWizardNode( new RepositoryWizardNode( repositoryElement ) );
+                    IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+                    IRepositoryType type = (IRepositoryType) sel.getFirstElement();
+                    repositoryElement = SigilCore.getRepositoryConfiguration().newRepositoryElement(
+                        type);
+                    selectWizardNode(new RepositoryWizardNode(repositoryElement));
                 }
             }
-        } );
+        });
 
-        ArrayList<IRepositoryType> descriptors = new ArrayList<IRepositoryType>( SigilCore.getRepositoryConfiguration()
-            .loadRepositoryTypes() );
+        ArrayList<IRepositoryType> descriptors = new ArrayList<IRepositoryType>(
+            SigilCore.getRepositoryConfiguration().loadRepositoryTypes());
 
-        for ( Iterator<IRepositoryType> i = descriptors.iterator(); i.hasNext(); )
+        for (Iterator<IRepositoryType> i = descriptors.iterator(); i.hasNext();)
         {
-            if ( !i.next().isDynamic() )
+            if (!i.next().isDynamic())
             {
                 i.remove();
             }
         }
 
-        repositoryView.setInput( descriptors );
+        repositoryView.setInput(descriptors);
 
-        setControl( control );
+        setControl(control);
     }
 
-
-    public void selectWizardNode( RepositoryWizardNode node )
+    public void selectWizardNode(RepositoryWizardNode node)
     {
-        setSelectedNode( node );
+        setSelectedNode(node);
     }
 
-
     public RepositoryWizardNode getSelectedWizardNode()
     {
-        return ( RepositoryWizardNode ) getSelectedNode();
+        return (RepositoryWizardNode) getSelectedNode();
     }
 
-
     public IRepositoryModel getRepository()
     {
         return repositoryElement;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryViewData.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryViewData.java
index b86756b..714bb12 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryViewData.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryViewData.java
@@ -19,42 +19,35 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
 
-
 class RepositoryViewData
 {
     private String name;
     private IRepositoryModel[] reps;
 
-
-    RepositoryViewData( String name, IRepositoryModel[] reps )
+    RepositoryViewData(String name, IRepositoryModel[] reps)
     {
         this.name = name;
         this.reps = reps;
     }
 
-
     String getName()
     {
         return name;
     }
 
-
     IRepositoryModel[] getRepositories()
     {
         return reps;
     }
 
-
-    void setName( String name )
+    void setName(String name)
     {
         this.name = name;
     }
 
-
-    void setRepositories( IRepositoryModel[] reps )
+    void setRepositories(IRepositoryModel[] reps)
     {
         this.reps = reps;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryWizardNode.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryWizardNode.java
index bbfda3b..6a4a7d6 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryWizardNode.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryWizardNode.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
 import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizard;
@@ -28,7 +27,6 @@
 import org.eclipse.jface.wizard.IWizardNode;
 import org.eclipse.swt.graphics.Point;
 
-
 public class RepositoryWizardNode implements IWizardNode
 {
 
@@ -36,53 +34,47 @@
 
     private RepositoryWizard wizard;
 
-
-    public RepositoryWizardNode( IRepositoryModel repository )
+    public RepositoryWizardNode(IRepositoryModel repository)
     {
         this.repository = repository;
     }
 
-
     public void dispose()
     {
-        if ( wizard != null )
+        if (wizard != null)
         {
             wizard.dispose();
             wizard = null;
         }
     }
 
-
     public Point getExtent()
     {
-        return new Point( -1, -1 );
+        return new Point(-1, -1);
     }
 
-
     public IWizard getWizard()
     {
-        if ( wizard == null )
+        if (wizard == null)
         {
             try
             {
-                wizard = WizardHelper.loadWizard( repository.getType() );
-                wizard.init( repository );
+                wizard = WizardHelper.loadWizard(repository.getType());
+                wizard.init(repository);
             }
-            catch ( CoreException e )
+            catch (CoreException e)
             {
-                SigilCore.error( "Failed to create wizard for " + repository.getType(), e );
+                SigilCore.error("Failed to create wizard for " + repository.getType(), e);
             }
         }
         return wizard;
     }
 
-
     public IRepositoryModel getRepository()
     {
         return repository;
     }
 
-
     public boolean isContentCreated()
     {
         return wizard != null;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/WizardHelper.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/WizardHelper.java
index aab59d5..43709bb 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/WizardHelper.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/WizardHelper.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryType;
 import org.apache.felix.sigil.eclipse.ui.SigilUI;
@@ -31,38 +30,36 @@
 import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.Platform;
 
-
 public class WizardHelper
 {
-    public static RepositoryWizard loadWizard( IRepositoryType type ) throws CoreException
+    public static RepositoryWizard loadWizard(IRepositoryType type) throws CoreException
     {
-        IConfigurationElement e = findWizardConfig( type.getId() );
+        IConfigurationElement e = findWizardConfig(type.getId());
 
-        if ( e == null )
+        if (e == null)
         {
-            throw SigilCore.newCoreException( "No wizard registered for repository " + type, null );
+            throw SigilCore.newCoreException("No wizard registered for repository "
+                + type, null);
         }
 
-        return ( RepositoryWizard ) e.createExecutableExtension( "class" );
+        return (RepositoryWizard) e.createExecutableExtension("class");
     }
 
-
-    public static boolean hasWizard( IRepositoryType type )
+    public static boolean hasWizard(IRepositoryType type)
     {
-        return findWizardConfig( type.getId() ) != null;
+        return findWizardConfig(type.getId()) != null;
     }
 
-
-    private static IConfigurationElement findWizardConfig( String id )
+    private static IConfigurationElement findWizardConfig(String id)
     {
         IExtensionRegistry registry = Platform.getExtensionRegistry();
-        IExtensionPoint p = registry.getExtensionPoint( SigilUI.REPOSITORY_WIZARD_EXTENSION_POINT_ID );
+        IExtensionPoint p = registry.getExtensionPoint(SigilUI.REPOSITORY_WIZARD_EXTENSION_POINT_ID);
 
-        for ( IExtension e : p.getExtensions() )
+        for (IExtension e : p.getExtensions())
         {
-            for ( IConfigurationElement c : e.getConfigurationElements() )
+            for (IConfigurationElement c : e.getConfigurationElements())
             {
-                if ( id.equals( c.getAttribute( "repository" ) ) )
+                if (id.equals(c.getAttribute("repository")))
                 {
                     return c;
                 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportPackageProposal.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportPackageProposal.java
index 3f16ee5..a9b8d3a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportPackageProposal.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportPackageProposal.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.quickfix;
 
-
 import org.apache.felix.sigil.common.model.ModelElementFactory;
 import org.apache.felix.sigil.common.model.ModelElementFactoryException;
 import org.apache.felix.sigil.common.model.osgi.IPackageExport;
@@ -37,84 +36,77 @@
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 
-
 public class ImportPackageProposal implements IJavaCompletionProposal
 {
 
     private IPackageExport e;
     private ISigilProjectModel n;
 
-
-    public ImportPackageProposal( IPackageExport e, ISigilProjectModel n )
+    public ImportPackageProposal(IPackageExport e, ISigilProjectModel n)
     {
         this.e = e;
         this.n = n;
     }
 
-
     public int getRelevance()
     {
         return 100;
     }
 
-
-    public void apply( IDocument document )
+    public void apply(IDocument document)
     {
         try
         {
 
-            final IPackageImport i = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
-            i.setPackageName( e.getPackageName() );
+            final IPackageImport i = ModelElementFactory.getInstance().newModelElement(
+                IPackageImport.class);
+            i.setPackageName(e.getPackageName());
             VersionRange selectedVersions = ModelHelper.getDefaultRange(e.getVersion());
-            i.setVersions( selectedVersions );
+            i.setVersions(selectedVersions);
 
             WorkspaceModifyOperation op = new WorkspaceModifyOperation()
             {
                 @Override
-                protected void execute( IProgressMonitor monitor ) throws CoreException
+                protected void execute(IProgressMonitor monitor) throws CoreException
                 {
-                    n.getBundle().getBundleInfo().addImport( i );
-                    n.save( monitor );
+                    n.getBundle().getBundleInfo().addImport(i);
+                    n.save(monitor);
                 }
             };
 
-            SigilUI.runWorkspaceOperation( op, null );
+            SigilUI.runWorkspaceOperation(op, null);
         }
-        catch ( ModelElementFactoryException e )
+        catch (ModelElementFactoryException e)
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
     }
 
-
     public String getAdditionalProposalInfo()
     {
         return null;
     }
 
-
     public IContextInformation getContextInformation()
     {
         // TODO Auto-generated method stub
         return null;
     }
 
-
     public String getDisplayString()
     {
-        return "Import package " + e.getPackageName() + " version " + e.getVersion() + " to bundle";
+        return "Import package " + e.getPackageName() + " version " + e.getVersion()
+            + " to bundle";
     }
 
-
     public Image getImage()
     {
         // TODO Auto-generated method stub
         return null;
     }
 
-
-    public Point getSelection( IDocument document )
+    public Point getSelection(IDocument document)
     {
         return null;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportQuickFixProcessor.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportQuickFixProcessor.java
index d4edee1..3f72696 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportQuickFixProcessor.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportQuickFixProcessor.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.quickfix;
 
-
 import java.util.ArrayList;
 import java.util.HashMap;
 
@@ -49,17 +48,15 @@
 import org.eclipse.jdt.ui.text.java.IProblemLocation;
 import org.eclipse.jdt.ui.text.java.IQuickFixProcessor;
 
-
 @SuppressWarnings("restriction")
 public class ImportQuickFixProcessor implements IQuickFixProcessor
 {
 
     private static final Object SYNC_FLAG = new Object();
 
-
-    public boolean hasCorrections( ICompilationUnit unit, int problemId )
+    public boolean hasCorrections(ICompilationUnit unit, int problemId)
     {
-        switch ( problemId )
+        switch (problemId)
         {
             case IProblem.ImportNotFound:
             case IProblem.ForbiddenReference:
@@ -71,156 +68,158 @@
         }
     }
 
-
-    public IJavaCompletionProposal[] getCorrections( IInvocationContext context, IProblemLocation[] locations )
-        throws CoreException
+    public IJavaCompletionProposal[] getCorrections(IInvocationContext context,
+        IProblemLocation[] locations) throws CoreException
     {
         try
         {
             HashMap<Object, IJavaCompletionProposal> results = new HashMap<Object, IJavaCompletionProposal>();
 
-            ISigilProjectModel project = findProject( context );
+            ISigilProjectModel project = findProject(context);
 
-            if ( project != null )
+            if (project != null)
             {
-                for ( int i = 0; i < locations.length; i++ )
+                for (int i = 0; i < locations.length; i++)
                 {
-                    switch ( locations[i].getProblemId() )
+                    switch (locations[i].getProblemId())
                     {
                         case IProblem.ForbiddenReference:
-                            handleImportNotFound( project, context, locations[i], results );
+                            handleImportNotFound(project, context, locations[i], results);
                             break;
                         case IProblem.ImportNotFound:
-                            handleImportNotFound( project, context, locations[i], results );
+                            handleImportNotFound(project, context, locations[i], results);
                             break;
                         case IProblem.IsClassPathCorrect:
-                            handleIsClassPathCorrect( project, context, locations[i], results );
+                            handleIsClassPathCorrect(project, context, locations[i],
+                                results);
                             break;
                         case IProblem.UndefinedType:
-                            handleUndefinedType( project, context, locations[i], results );
+                            handleUndefinedType(project, context, locations[i], results);
                             break;
                         case IProblem.UndefinedName:
-                            handleUndefinedName( project, context, locations[i], results );
+                            handleUndefinedName(project, context, locations[i], results);
                             break;
                     }
                 }
             }
 
-            return ( IJavaCompletionProposal[] ) results.values().toArray( new IJavaCompletionProposal[results.size()] );
+            return (IJavaCompletionProposal[]) results.values().toArray(
+                new IJavaCompletionProposal[results.size()]);
         }
-        catch ( RuntimeException e )
+        catch (RuntimeException e)
         {
             e.printStackTrace();
             throw e;
         }
     }
 
-
-    private void handleUndefinedName( ISigilProjectModel project, IInvocationContext context, IProblemLocation problem,
-        HashMap<Object, IJavaCompletionProposal> results )
+    private void handleUndefinedName(ISigilProjectModel project,
+        IInvocationContext context, IProblemLocation problem,
+        HashMap<Object, IJavaCompletionProposal> results)
     {
-        Name node = findNode( context, problem );
+        Name node = findNode(context, problem);
 
-        if ( node == null )
+        if (node == null)
         {
             return;
         }
-        addSearchResults( node, project, results );
+        addSearchResults(node, project, results);
     }
 
-
-    private void handleIsClassPathCorrect( ISigilProjectModel project, final IInvocationContext context,
-        IProblemLocation problemLocation, final HashMap<Object, IJavaCompletionProposal> results )
+    private void handleIsClassPathCorrect(ISigilProjectModel project,
+        final IInvocationContext context, IProblemLocation problemLocation,
+        final HashMap<Object, IJavaCompletionProposal> results)
     {
-        for ( final String type : problemLocation.getProblemArguments() )
+        for (final String type : problemLocation.getProblemArguments())
         {
-            final String iPackage = type.substring( 0, type.lastIndexOf( "." ) );
+            final String iPackage = type.substring(0, type.lastIndexOf("."));
 
-            for ( IPackageExport pe : JavaHelper.findExportsForPackage( project, iPackage ) )
+            for (IPackageExport pe : JavaHelper.findExportsForPackage(project, iPackage))
             {
-                results.put( type, new ImportPackageProposal( pe, project ) );
+                results.put(type, new ImportPackageProposal(pe, project));
             }
         }
 
-        if ( !results.containsKey( SYNC_FLAG ) )
+        if (!results.containsKey(SYNC_FLAG))
         {
             //results.put( SYNC_FLAG, null);
         }
     }
 
-
-    private void handleUndefinedType( ISigilProjectModel project, IInvocationContext context, IProblemLocation problem,
-        HashMap<Object, IJavaCompletionProposal> results ) throws CoreException
+    private void handleUndefinedType(ISigilProjectModel project,
+        IInvocationContext context, IProblemLocation problem,
+        HashMap<Object, IJavaCompletionProposal> results) throws CoreException
     {
-        Name node = findNode( context, problem );
+        Name node = findNode(context, problem);
 
-        if ( node == null )
+        if (node == null)
         {
             return;
         }
-        addSearchResults( node, project, results );
+        addSearchResults(node, project, results);
     }
 
-
-    private void handleImportNotFound( ISigilProjectModel project, final IInvocationContext context,
-        IProblemLocation location, final HashMap<Object, IJavaCompletionProposal> results ) throws CoreException
+    private void handleImportNotFound(ISigilProjectModel project,
+        final IInvocationContext context, IProblemLocation location,
+        final HashMap<Object, IJavaCompletionProposal> results) throws CoreException
     {
-        ASTNode selectedNode = location.getCoveringNode( context.getASTRoot() );
-        if ( selectedNode == null )
+        ASTNode selectedNode = location.getCoveringNode(context.getASTRoot());
+        if (selectedNode == null)
             return;
 
-        if ( selectedNode instanceof ClassInstanceCreation )
+        if (selectedNode instanceof ClassInstanceCreation)
         {
-            ClassInstanceCreation c = ( ClassInstanceCreation ) selectedNode;
+            ClassInstanceCreation c = (ClassInstanceCreation) selectedNode;
             Type t = c.getType();
-            Name node = findName( t );
-            if ( node != null )
+            Name node = findName(t);
+            if (node != null)
             {
-                addSearchResults( node, project, results );
+                addSearchResults(node, project, results);
             }
         }
         else
         {
-            for ( final String iPackage : readPackage( selectedNode, location ) )
+            for (final String iPackage : readPackage(selectedNode, location))
             {
-                if ( !results.containsKey( iPackage ) )
+                if (!results.containsKey(iPackage))
                 {
-                    for ( IPackageExport pe : JavaHelper.findExportsForPackage( project, iPackage ) )
+                    for (IPackageExport pe : JavaHelper.findExportsForPackage(project,
+                        iPackage))
                     {
-                        results.put( iPackage, new ImportPackageProposal( pe, project ) );
+                        results.put(iPackage, new ImportPackageProposal(pe, project));
                     }
                 }
             }
         }
     }
 
-
-    private void addSearchResults( Name node, ISigilProjectModel project,
-        HashMap<Object, IJavaCompletionProposal> results )
+    private void addSearchResults(Name node, ISigilProjectModel project,
+        HashMap<Object, IJavaCompletionProposal> results)
     {
-        for ( ISearchResult result : SigilSearch.findProviders( node.getFullyQualifiedName(), project, null ) )
+        for (ISearchResult result : SigilSearch.findProviders(
+            node.getFullyQualifiedName(), project, null))
         {
-            if ( project.getBundle().findImport( result.getPackageName() ) == null )
+            if (project.getBundle().findImport(result.getPackageName()) == null)
             {
-                String type = result.getPackageName() + "." + node.getFullyQualifiedName();
-                results.put( type, new ImportSearchResultProposal( SigilUI.getActiveWorkbenchShell(), result, node,
-                    project ) );
+                String type = result.getPackageName() + "."
+                    + node.getFullyQualifiedName();
+                results.put(type, new ImportSearchResultProposal(
+                    SigilUI.getActiveWorkbenchShell(), result, node, project));
             }
         }
     }
 
-
-    private Name findName( Type t )
+    private Name findName(Type t)
     {
-        if ( t.isSimpleType() )
+        if (t.isSimpleType())
         {
-            SimpleType st = ( SimpleType ) t;
+            SimpleType st = (SimpleType) t;
             return st.getName();
         }
-        else if ( t.isArrayType() )
+        else if (t.isArrayType())
         {
-            ArrayType at = ( ArrayType ) t;
-            return findName( at.getElementType() );
+            ArrayType at = (ArrayType) t;
+            return findName(at.getElementType());
         }
         else
         {
@@ -228,41 +227,40 @@
         }
     }
 
-
-    private Name findNode( IInvocationContext context, IProblemLocation problem )
+    private Name findNode(IInvocationContext context, IProblemLocation problem)
     {
-        ASTNode selectedNode = problem.getCoveringNode( context.getASTRoot() );
-        if ( selectedNode == null )
+        ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
+        if (selectedNode == null)
         {
             return null;
         }
 
-        while ( selectedNode.getLocationInParent() == QualifiedName.NAME_PROPERTY )
+        while (selectedNode.getLocationInParent() == QualifiedName.NAME_PROPERTY)
         {
             selectedNode = selectedNode.getParent();
         }
 
         Name node = null;
 
-        if ( selectedNode instanceof Type )
+        if (selectedNode instanceof Type)
         {
-            node = findName( ( Type ) selectedNode );
+            node = findName((Type) selectedNode);
         }
-        else if ( selectedNode instanceof Name )
+        else if (selectedNode instanceof Name)
         {
-            node = ( Name ) selectedNode;
+            node = (Name) selectedNode;
         }
 
         return node;
     }
 
-
-    private ISigilProjectModel findProject( IInvocationContext context ) throws CoreException
+    private ISigilProjectModel findProject(IInvocationContext context)
+        throws CoreException
     {
         IProject project = context.getCompilationUnit().getJavaProject().getProject();
-        if ( project.hasNature( SigilCore.NATURE_ID ) )
+        if (project.hasNature(SigilCore.NATURE_ID))
         {
-            return SigilCore.create( project );
+            return SigilCore.create(project);
         }
         else
         {
@@ -270,45 +268,46 @@
         }
     }
 
-
-    private String[] readPackage( ASTNode selectedNode, IProblemLocation location )
+    private String[] readPackage(ASTNode selectedNode, IProblemLocation location)
     {
         ArrayList<String> packages = new ArrayList<String>();
 
-        ImportDeclaration id = ( ImportDeclaration ) ASTNodes.getParent( selectedNode, ASTNode.IMPORT_DECLARATION );
+        ImportDeclaration id = (ImportDeclaration) ASTNodes.getParent(selectedNode,
+            ASTNode.IMPORT_DECLARATION);
 
-        if ( id == null )
+        if (id == null)
         {
-            MethodInvocation m = ( MethodInvocation ) ASTNodes.getParent( selectedNode, ASTNode.METHOD_INVOCATION );
+            MethodInvocation m = (MethodInvocation) ASTNodes.getParent(selectedNode,
+                ASTNode.METHOD_INVOCATION);
 
-            if ( m != null )
+            if (m != null)
             {
-                packages.add( readPackage( m ) );
-                while ( m.getExpression() != null && m.getExpression() instanceof MethodInvocation )
+                packages.add(readPackage(m));
+                while (m.getExpression() != null
+                    && m.getExpression() instanceof MethodInvocation)
                 {
-                    m = ( MethodInvocation ) m.getExpression();
-                    packages.add( readPackage( m ) );
+                    m = (MethodInvocation) m.getExpression();
+                    packages.add(readPackage(m));
                 }
             }
         }
         else
         {
-            if ( id.isOnDemand() )
+            if (id.isOnDemand())
             {
-                packages.add( id.getName().toString() );
+                packages.add(id.getName().toString());
             }
             else
             {
                 String iStr = id.getName().toString();
-                packages.add( iStr.substring( 0, iStr.lastIndexOf( "." ) ) );
+                packages.add(iStr.substring(0, iStr.lastIndexOf(".")));
             }
         }
 
-        return packages.toArray( new String[packages.size()] );
+        return packages.toArray(new String[packages.size()]);
     }
 
-
-    private String readPackage( MethodInvocation m )
+    private String readPackage(MethodInvocation m)
     {
         return m.resolveMethodBinding().getDeclaringClass().getPackage().getName();
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportSearchResultProposal.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportSearchResultProposal.java
index efcd9bf..60210b4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportSearchResultProposal.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportSearchResultProposal.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.quickfix;
 
-
 import org.apache.felix.sigil.common.model.ModelElementFactory;
 import org.apache.felix.sigil.common.model.osgi.IPackageExport;
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
@@ -51,7 +50,6 @@
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 import org.osgi.framework.Version;
 
-
 public class ImportSearchResultProposal implements IJavaCompletionProposal
 {
 
@@ -60,123 +58,124 @@
     private final ISearchResult result;
     private final Shell shell;
 
-
-    public ImportSearchResultProposal( Shell shell, ISearchResult result, Name node, ISigilProjectModel project )
+    public ImportSearchResultProposal(Shell shell, ISearchResult result, Name node, ISigilProjectModel project)
     {
         this.shell = shell;
         this.result = result;
         this.project = project;
-        if ( node != null )
+        if (node != null)
         {
-            CompilationUnit cu = ( CompilationUnit ) ASTNodes.getParent( node, ASTNode.COMPILATION_UNIT );
-            this.fCompilationUnit = ( ICompilationUnit ) cu.getJavaElement();
+            CompilationUnit cu = (CompilationUnit) ASTNodes.getParent(node,
+                ASTNode.COMPILATION_UNIT);
+            this.fCompilationUnit = (ICompilationUnit) cu.getJavaElement();
         }
     }
 
-
     public int getRelevance()
     {
         return 100;
     }
 
-
-    public void apply( IDocument document )
+    public void apply(IDocument document)
     {
         IPackageExport e = result.getExport();
-        if ( result.getExport() == null )
+        if (result.getExport() == null)
         {
-            if ( MessageDialog.openQuestion( shell, "Modify " + result.getProvider().getBundleInfo().getSymbolicName(),
-                result.getPackageName() + " is not exported. Do you want to export it now?" ) )
+            if (MessageDialog.openQuestion(shell, "Modify "
+                + result.getProvider().getBundleInfo().getSymbolicName(),
+                result.getPackageName()
+                    + " is not exported. Do you want to export it now?"))
             {
-                final IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
-                pe.setPackageName( result.getPackageName() );
+                final IPackageExport pe = ModelElementFactory.getInstance().newModelElement(
+                    IPackageExport.class);
+                pe.setPackageName(result.getPackageName());
                 //e.setVersion(version)
-                final ISigilProjectModel mod = result.getProvider().getAncestor( ISigilProjectModel.class );
-                if ( mod == null )
+                final ISigilProjectModel mod = result.getProvider().getAncestor(
+                    ISigilProjectModel.class);
+                if (mod == null)
                 {
-                    throw new IllegalStateException( "Attempt to modify binary package export" );
+                    throw new IllegalStateException(
+                        "Attempt to modify binary package export");
                 }
                 WorkspaceModifyOperation op = new WorkspaceModifyOperation()
                 {
                     @Override
-                    protected void execute( IProgressMonitor monitor ) throws CoreException
+                    protected void execute(IProgressMonitor monitor) throws CoreException
                     {
-                        mod.getBundle().getBundleInfo().addExport( pe );
-                        mod.save( monitor );
+                        mod.getBundle().getBundleInfo().addExport(pe);
+                        mod.save(monitor);
                     }
                 };
 
-                SigilUI.runWorkspaceOperation( op, null );
+                SigilUI.runWorkspaceOperation(op, null);
                 e = pe;
             }
         }
 
-        final IPackageImport i = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
-        i.setPackageName( e.getPackageName() );
+        final IPackageImport i = ModelElementFactory.getInstance().newModelElement(
+            IPackageImport.class);
+        i.setPackageName(e.getPackageName());
         VersionRange selectedVersions = ModelHelper.getDefaultRange(e.getVersion());
-        i.setVersions( selectedVersions );
+        i.setVersions(selectedVersions);
 
         WorkspaceModifyOperation op = new WorkspaceModifyOperation()
         {
             @Override
-            protected void execute( IProgressMonitor monitor ) throws CoreException
+            protected void execute(IProgressMonitor monitor) throws CoreException
             {
-                project.getBundle().getBundleInfo().addImport( i );
-                project.save( null );
+                project.getBundle().getBundleInfo().addImport(i);
+                project.save(null);
             }
         };
 
-        SigilUI.runWorkspaceOperation( op, null );
+        SigilUI.runWorkspaceOperation(op, null);
         addSourceImport();
     }
 
-
     private void addSourceImport()
     {
         // add import
         try
         {
-            ImportRewrite rewrite = CodeStyleConfiguration.createImportRewrite( fCompilationUnit, true );
-            rewrite.addImport( result.getClassName() );
-            JavaModelUtil.applyEdit( fCompilationUnit, rewrite.rewriteImports( null ), false, null );
+            ImportRewrite rewrite = CodeStyleConfiguration.createImportRewrite(
+                fCompilationUnit, true);
+            rewrite.addImport(result.getClassName());
+            JavaModelUtil.applyEdit(fCompilationUnit, rewrite.rewriteImports(null),
+                false, null);
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to add import", e );
+            SigilCore.error("Failed to add import", e);
         }
     }
 
-
     public String getAdditionalProposalInfo()
     {
         return null;
     }
 
-
     public IContextInformation getContextInformation()
     {
         // TODO Auto-generated method stub
         return null;
     }
 
-
     public String getDisplayString()
     {
         String type = result.getClassName();
-        String loc = result.getExport() == null ? " from " + result.getProvider().getBundleInfo().getSymbolicName()
-            : " version " + result.getExport().getVersion();
+        String loc = result.getExport() == null ? " from "
+            + result.getProvider().getBundleInfo().getSymbolicName() : " version "
+            + result.getExport().getVersion();
         return "Import " + type + loc;
     }
 
-
     public Image getImage()
     {
         // TODO Auto-generated method stub
         return null;
     }
 
-
-    public Point getSelection( IDocument document )
+    public Point getSelection(IDocument document)
     {
         return null;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportedClassReference.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportedClassReference.java
index 363e089..b5c787d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportedClassReference.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportedClassReference.java
@@ -19,29 +19,24 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.quickfix;
 
-
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 
-
 public class ImportedClassReference
 {
     private IPackageImport pi;
     private String type;
 
-
-    public ImportedClassReference( IPackageImport packageImport, String typeName )
+    public ImportedClassReference(IPackageImport packageImport, String typeName)
     {
         this.pi = packageImport;
         this.type = typeName;
     }
 
-
     public IPackageImport getPackageImport()
     {
         return pi;
     }
 
-
     public String getFullType()
     {
         return type;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/BundleActivatorChange.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/BundleActivatorChange.java
index 41f6806..773264c 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/BundleActivatorChange.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/BundleActivatorChange.java
@@ -75,7 +75,7 @@
     public void initializeValidationData(IProgressMonitor monitor)
     {
         // TODO Auto-generated method stub
-        
+
     }
 
     /* (non-Javadoc)
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
index ab0233e..df1d34d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
@@ -78,17 +78,19 @@
 
     @Override
     public Change perform(IProgressMonitor progress) throws CoreException
-    {   
-        if (oldExport != null) {
+    {
+        if (oldExport != null)
+        {
             sigil.getBundle().getBundleInfo().removeChild(oldExport);
         }
-        
-        if (newExport != null) {
+
+        if (newExport != null)
+        {
             sigil.getBundle().getBundleInfo().addExport(newExport);
         }
-        
+
         sigil.save(progress);
-        
+
         return new ExportPackageChange(sigil, newExport, oldExport);
     }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ImportPackageChange.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ImportPackageChange.java
index 9537a3d..cf3b990 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ImportPackageChange.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ImportPackageChange.java
@@ -72,16 +72,18 @@
     @Override
     public Change perform(IProgressMonitor progress) throws CoreException
     {
-        if (oldImport!=null) {
+        if (oldImport != null)
+        {
             sigil.getBundle().getBundleInfo().removeImport(oldImport);
         }
-        
-        if (newImport != null) {
+
+        if (newImport != null)
+        {
             sigil.getBundle().getBundleInfo().addImport(newImport);
         }
-        
+
         sigil.save(progress);
-        
+
         return new ImportPackageChange(sigil, newImport, oldImport);
     }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MoveActivatorParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MoveActivatorParticipant.java
index 205be07..f45a4e9 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MoveActivatorParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MoveActivatorParticipant.java
@@ -47,19 +47,22 @@
         CheckConditionsContext ctx) throws OperationCanceledException
     {
         RefactoringStatus status = null;
-        if(getArguments().getUpdateReferences()) {
+        if (getArguments().getUpdateReferences())
+        {
             IPackageFragment pf = (IPackageFragment) compilationUnit.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
             String oldName = qualifiedName(pf, compilationUnit.getElementName());
             try
             {
                 ISigilProjectModel sigil = SigilCore.create(compilationUnit.getJavaProject().getProject());
-                if (oldName.equals(sigil.getBundle().getBundleInfo().getActivator())) {
+                if (oldName.equals(sigil.getBundle().getBundleInfo().getActivator()))
+                {
                     IPackageFragment dest = (IPackageFragment) getArguments().getDestination();
                     String newName = qualifiedName(dest, compilationUnit.getElementName());
-                    
+
                     RefactorUtil.touch(ctx, sigil);
                     changes.add(new BundleActivatorChange(sigil, oldName, newName));
-                    status = RefactoringStatus.createInfoStatus("Updating bundle activator from " + oldName + " to " + newName );
+                    status = RefactoringStatus.createInfoStatus("Updating bundle activator from "
+                        + oldName + " to " + newName);
                 }
             }
             catch (CoreException e)
@@ -67,7 +70,7 @@
                 SigilCore.warn("Failed to update activator", e);
             }
         }
-        
+
         return status;
     }
 
@@ -86,15 +89,16 @@
     public Change createChange(IProgressMonitor monitor) throws CoreException,
         OperationCanceledException
     {
-        if (changes.isEmpty()) {
+        if (changes.isEmpty())
+        {
             return new NullChange();
         }
-        else 
+        else
         {
             CompositeChange ret = new CompositeChange("Export-Package update");
-            
+
             ret.addAll(changes.toArray(new Change[changes.size()]));
-            
+
             return ret;
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
index 389b9a3..7cfb4f7 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
@@ -52,50 +52,69 @@
     public RefactoringStatus checkConditions(IProgressMonitor monitor,
         CheckConditionsContext context) throws OperationCanceledException
     {
-        if (getArguments().getUpdateReferences()) {
+        if (getArguments().getUpdateReferences())
+        {
             try
             {
                 ISigilProjectModel sourceProject = SigilCore.create(packageFragment.getJavaProject().getProject());
                 IPackageFragmentRoot dest = (IPackageFragmentRoot) getArguments().getDestination();
                 ISigilProjectModel destProject = SigilCore.create(dest.getJavaProject().getProject());
-                
+
                 RefactoringStatus status = new RefactoringStatus();
-                if ( !sourceProject.equals(destProject) ) {                    
+                if (!sourceProject.equals(destProject))
+                {
                     RefactorUtil.touch(context, sourceProject);
                     RefactorUtil.touch(context, destProject);
-                    
+
                     final String packageName = packageFragment.getElementName();
-                    IPackageExport oldExport = ModelHelper.findExport(sourceProject, packageName);
-                    
-                    if (oldExport != null) {
-                        IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);
-                        
+                    IPackageExport oldExport = ModelHelper.findExport(sourceProject,
+                        packageName);
+
+                    if (oldExport != null)
+                    {
+                        IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
+                            IPackageExport.class);
+
                         newExport.setPackageName(oldExport.getPackageName());
                         newExport.setVersion(oldExport.getRawVersion());
-                        
-                        changes.add(new ExportPackageChange(destProject,null, newExport));
-                        changes.add(new ExportPackageChange(sourceProject, oldExport, null));
-                        
-                        status.addWarning("Package " + packageName + " is exported from " + sourceProject.getSymbolicName() + ", this may effect client bundles that use require bundle");
-                    }
-                    else {
-                        SubMonitor sub = SubMonitor.convert(monitor);
-                        
-                        Set<String> users = JavaHelper.findLocalPackageUsers(sourceProject, packageName, sub.newChild(100));
-                        Set<String> dependencies = JavaHelper.findLocalPackageDependencies(sourceProject, packageName, sub.newChild(100));
 
-                        if (users.size() > 0 && dependencies.size() > 0) {
-                            status.addWarning("Package " + packageName + " is coupled to " + users + " and " + dependencies + " this may cause a cyclical dependency");
+                        changes.add(new ExportPackageChange(destProject, null, newExport));
+                        changes.add(new ExportPackageChange(sourceProject, oldExport,
+                            null));
+
+                        status.addWarning("Package " + packageName + " is exported from "
+                            + sourceProject.getSymbolicName()
+                            + ", this may effect client bundles that use require bundle");
+                    }
+                    else
+                    {
+                        SubMonitor sub = SubMonitor.convert(monitor);
+
+                        Set<String> users = JavaHelper.findLocalPackageUsers(
+                            sourceProject, packageName, sub.newChild(100));
+                        Set<String> dependencies = JavaHelper.findLocalPackageDependencies(
+                            sourceProject, packageName, sub.newChild(100));
+
+                        if (users.size() > 0 && dependencies.size() > 0)
+                        {
+                            status.addWarning("Package " + packageName
+                                + " is coupled to " + users + " and " + dependencies
+                                + " this may cause a cyclical dependency");
                         }
-                        
-                        if (users.size() > 0) { // attempt to move an API package
-                            IPackageExport newExport = createNewExport(status, destProject, packageName);
+
+                        if (users.size() > 0)
+                        { // attempt to move an API package
+                            IPackageExport newExport = createNewExport(status,
+                                destProject, packageName);
                             createNewImport(status, sourceProject, newExport);
                         }
-                        
-                        if (dependencies.size() > 0){ // moved an impl package
-                            for (String dep : dependencies) {
-                                IPackageExport newExport = createNewExport(status, sourceProject, dep);
+
+                        if (dependencies.size() > 0)
+                        { // moved an impl package
+                            for (String dep : dependencies)
+                            {
+                                IPackageExport newExport = createNewExport(status,
+                                    sourceProject, dep);
                                 createNewImport(status, destProject, newExport);
                             }
                         }
@@ -109,32 +128,36 @@
                 throw new OperationCanceledException(e.getMessage());
             }
         }
-        else {
+        else
+        {
             return new RefactoringStatus();
         }
     }
 
-    private void createNewImport(RefactoringStatus status,
-        ISigilProjectModel project, IPackageExport export)
+    private void createNewImport(RefactoringStatus status, ISigilProjectModel project,
+        IPackageExport export)
     {
-        IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
+        IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(
+            IPackageImport.class);
         newImport.setPackageName(export.getPackageName());
         newImport.setVersions(ModelHelper.getDefaultRange(export.getVersion()));
-        
+
         status.addInfo("Creating new import in " + project.getSymbolicName());
-        changes.add( new ImportPackageChange(project, null, newImport));                            
+        changes.add(new ImportPackageChange(project, null, newImport));
     }
 
     private IPackageExport createNewExport(RefactoringStatus status,
         ISigilProjectModel project, String packageName)
     {
-        IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);                            
-        newExport.setPackageName(packageName);                            
+        IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
+            IPackageExport.class);
+        newExport.setPackageName(packageName);
         // new export inherits project version by default
         newExport.setVersion(project.getVersion());
-        
-        status.addInfo("Creating new export " + packageName + " in " + project.getSymbolicName());
-        changes.add( new ExportPackageChange(project, null, newExport));
+
+        status.addInfo("Creating new export " + packageName + " in "
+            + project.getSymbolicName());
+        changes.add(new ExportPackageChange(project, null, newExport));
         return newExport;
     }
 
@@ -142,15 +165,16 @@
     public Change createChange(IProgressMonitor monitor) throws CoreException,
         OperationCanceledException
     {
-        if (changes.isEmpty()) {
+        if (changes.isEmpty())
+        {
             return new NullChange();
         }
-        else 
+        else
         {
             CompositeChange ret = new CompositeChange("Export-Package update");
-            
+
             ret.addAll(changes.toArray(new Change[changes.size()]));
-            
+
             return ret;
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
index 327e47d..017bc15 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
@@ -35,7 +35,7 @@
     static final void touch(CheckConditionsContext context, ISigilProjectModel sigil)
     {
         ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
-        IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();        
+        IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
         IFile file = sigil.getProject().getFile(SigilCore.SIGIL_PROJECT_FILE);
         deltaFactory.change(file);
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorPackageParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorPackageParticipant.java
index a73bfc6..d62c501 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorPackageParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorPackageParticipant.java
@@ -45,19 +45,23 @@
         CheckConditionsContext ctx) throws OperationCanceledException
     {
         RefactoringStatus status = null;
-        if(getArguments().getUpdateReferences()) {
+        if (getArguments().getUpdateReferences())
+        {
             try
             {
                 ISigilProjectModel sigil = SigilCore.create(packageFragment.getJavaProject().getProject());
                 RefactorUtil.touch(ctx, sigil);
-                
+
                 String oldName = sigil.getBundle().getBundleInfo().getActivator();
-                if ( oldName != null ) {
+                if (oldName != null)
+                {
                     String[] parts = splitPackageClass(oldName);
-                    if (parts[0].equals(packageFragment.getElementName())) {
+                    if (parts[0].equals(packageFragment.getElementName()))
+                    {
                         String newName = getArguments().getNewName() + "." + parts[1];
                         changes.add(new BundleActivatorChange(sigil, oldName, newName));
-                        status = RefactoringStatus.createInfoStatus("Updating bundle activator from " + oldName + " to " + newName );
+                        status = RefactoringStatus.createInfoStatus("Updating bundle activator from "
+                            + oldName + " to " + newName);
                     }
                 }
             }
@@ -66,7 +70,7 @@
                 SigilCore.warn("Failed to update activator", e);
             }
         }
-        
+
         return status;
     }
 
@@ -74,11 +78,13 @@
     {
         String[] parts = new String[2];
         int i = className.lastIndexOf('.');
-        if ( i == -1 ) {
+        if (i == -1)
+        {
             parts[0] = "";
             parts[1] = className;
         }
-        else {
+        else
+        {
             parts[0] = className.substring(0, i);
             parts[1] = className.substring(i + 1);
         }
@@ -89,22 +95,23 @@
     public Change createChange(IProgressMonitor monitor) throws CoreException,
         OperationCanceledException
     {
-        if (changes.isEmpty()) {
+        if (changes.isEmpty())
+        {
             return new NullChange();
         }
-        else 
+        else
         {
             CompositeChange ret = new CompositeChange("Export-Package update");
-            
+
             ret.addAll(changes.toArray(new Change[changes.size()]));
-            
+
             return ret;
         }
     }
 
     @Override
     public String getName()
-    {        
+    {
         return "Sigil Rename Activator Package Participant";
     }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorParticipant.java
index 79a6d4c..60b6d81 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorParticipant.java
@@ -47,18 +47,21 @@
         CheckConditionsContext ctx) throws OperationCanceledException
     {
         RefactoringStatus status = null;
-        if(getArguments().getUpdateReferences()) {
+        if (getArguments().getUpdateReferences())
+        {
             IPackageFragment pf = (IPackageFragment) compilationUnit.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
             String oldName = qualifiedName(pf, compilationUnit.getElementName());
             try
             {
                 ISigilProjectModel sigil = SigilCore.create(compilationUnit.getJavaProject().getProject());
-                if (oldName.equals(sigil.getBundle().getBundleInfo().getActivator())) {
+                if (oldName.equals(sigil.getBundle().getBundleInfo().getActivator()))
+                {
                     String newName = qualifiedName(pf, getArguments().getNewName());
-                    
+
                     RefactorUtil.touch(ctx, sigil);
                     changes.add(new BundleActivatorChange(sigil, oldName, newName));
-                    status = RefactoringStatus.createInfoStatus("Updating bundle activator from " + oldName + " to " + newName );
+                    status = RefactoringStatus.createInfoStatus("Updating bundle activator from "
+                        + oldName + " to " + newName);
                 }
             }
             catch (CoreException e)
@@ -66,7 +69,7 @@
                 SigilCore.warn("Failed to update activator", e);
             }
         }
-        
+
         return status;
     }
 
@@ -85,15 +88,16 @@
     public Change createChange(IProgressMonitor monitor) throws CoreException,
         OperationCanceledException
     {
-        if (changes.isEmpty()) {
+        if (changes.isEmpty())
+        {
             return new NullChange();
         }
-        else 
+        else
         {
             CompositeChange ret = new CompositeChange("Export-Package update");
-            
+
             ret.addAll(changes.toArray(new Change[changes.size()]));
-            
+
             return ret;
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenamePackageParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenamePackageParticipant.java
index c1aabba..36382de 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenamePackageParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenamePackageParticipant.java
@@ -49,47 +49,57 @@
     @Override
     public RefactoringStatus checkConditions(IProgressMonitor pm,
         CheckConditionsContext context) throws OperationCanceledException
-    {   
+    {
         RefactoringStatus status = new RefactoringStatus();
-        
-        if (getArguments().getUpdateReferences()) {
+
+        if (getArguments().getUpdateReferences())
+        {
             try
             {
                 ISigilProjectModel sigil = SigilCore.create(packageFragment.getJavaProject().getProject());
                 final String packageName = packageFragment.getElementName();
-                
+
                 SigilCore.log("Rename checkConditions " + packageName);
-                
+
                 IPackageExport oldExport = ModelHelper.findExport(sigil, packageName);
-                
-                if (oldExport != null) {
+
+                if (oldExport != null)
+                {
                     // record change to check if out of sync...
                     RefactorUtil.touch(context, sigil);
-                                
-                    status = RefactoringStatus.createWarningStatus("Package " + packageName + " is exported. Renaming this package may effect bundles outside of this workspace");
-                    SigilCore.log("Export Package " + packageName + " renamed to " + getArguments().getNewName());
-    
-                    IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);
+
+                    status = RefactoringStatus.createWarningStatus("Package "
+                        + packageName
+                        + " is exported. Renaming this package may effect bundles outside of this workspace");
+                    SigilCore.log("Export Package " + packageName + " renamed to "
+                        + getArguments().getNewName());
+
+                    IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
+                        IPackageExport.class);
                     newExport.setPackageName(getArguments().getNewName());
                     newExport.setVersion(oldExport.getVersion());
-    
-                    changes.add(new ExportPackageChange(sigil, oldExport, newExport));                    
-    
-                    for ( ISigilProjectModel other : SigilCore.getRoot().getProjects() ) {
-                        if ( !sigil.equals(other) ) {
+
+                    changes.add(new ExportPackageChange(sigil, oldExport, newExport));
+
+                    for (ISigilProjectModel other : SigilCore.getRoot().getProjects())
+                    {
+                        if (!sigil.equals(other))
+                        {
                             // record change to check if out of sync...
                             RefactorUtil.touch(context, other);
                         }
-                        changes.add(createImportChange(status, other, oldExport, newExport));
+                        changes.add(createImportChange(status, other, oldExport,
+                            newExport));
                     }
                 }
             }
             catch (CoreException e)
             {
                 SigilCore.warn("Failed to create export package refactor", e);
-                throw new OperationCanceledException("Failed to create export package refactor");
+                throw new OperationCanceledException(
+                    "Failed to create export package refactor");
             }
-        }        
+        }
         return status;
     }
 
@@ -97,15 +107,16 @@
     public Change createChange(IProgressMonitor pm) throws CoreException,
         OperationCanceledException
     {
-        if (changes.isEmpty()) {
+        if (changes.isEmpty())
+        {
             return new NullChange();
         }
-        else 
+        else
         {
             CompositeChange ret = new CompositeChange("Export-Package update");
-            
+
             ret.addAll(changes.toArray(new Change[changes.size()]));
-            
+
             return ret;
         }
     }
@@ -123,24 +134,28 @@
         return true;
     }
 
-    private Change createImportChange(RefactoringStatus status, ISigilProjectModel sigil, IPackageExport oldExport, IPackageExport newExport)
+    private Change createImportChange(RefactoringStatus status, ISigilProjectModel sigil,
+        IPackageExport oldExport, IPackageExport newExport)
     {
         IBundleModelElement info = sigil.getBundle().getBundleInfo();
         Collection<IPackageImport> imports = info.getImports();
-        
-        for (IPackageImport oldImport : imports) {
-            if (oldImport.accepts(oldExport)) {
-                IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
-                
+
+        for (IPackageImport oldImport : imports)
+        {
+            if (oldImport.accepts(oldExport))
+            {
+                IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(
+                    IPackageImport.class);
+
                 newImport.setPackageName(newExport.getPackageName());
                 newImport.setVersions(oldImport.getVersions());
-                
+
                 status.addInfo(buildImportChangeMsg(sigil, oldImport, newImport));
-                
+
                 return new ImportPackageChange(sigil, oldImport, newImport);
             }
         }
-        
+
         // ok no change
         return new NullChange();
     }
@@ -148,9 +163,10 @@
     private static final String buildImportChangeMsg(ISigilProjectModel sigil,
         IPackageImport oldImport, IPackageImport newImport)
     {
-        return "Updating import " + oldImport.getPackageName() + " version " + oldImport.getVersions() +
-            " to " + newImport.getPackageName() + " version " + newImport.getVersions() +
-            " in project " + sigil.getSymbolicName() + " version " + sigil.getVersion();
+        return "Updating import " + oldImport.getPackageName() + " version "
+            + oldImport.getVersions() + " to " + newImport.getPackageName() + " version "
+            + newImport.getVersions() + " in project " + sigil.getSymbolicName()
+            + " version " + sigil.getVersion();
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizard.java
index 87b6c5b..1c27230 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizard.java
@@ -19,15 +19,13 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.repository;
 
-
 import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizard;
 
-
 public class FileSystemRepositoryWizard extends RepositoryWizard
 {
     @Override
     public void addPages()
     {
-        addPage( new FileSystemRepositoryWizardPage( this ) );
+        addPage(new FileSystemRepositoryWizardPage(this));
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizardPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizardPage.java
index 67c56b2..5e5b935 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizardPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizardPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.repository;
 
-
 import java.io.File;
 
 import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizard;
@@ -30,54 +29,51 @@
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 
-
 public class FileSystemRepositoryWizardPage extends RepositoryWizardPage implements IWizardPage
 {
 
     private DirectoryFieldEditor dirEditor;
 
-
-    protected FileSystemRepositoryWizardPage( RepositoryWizard parent )
+    protected FileSystemRepositoryWizardPage(RepositoryWizard parent)
     {
-        super( "File System Repository", parent );
+        super("File System Repository", parent);
     }
 
-
     @Override
     public void createFieldEditors()
     {
-        dirEditor = new DirectoryFieldEditor( "dir", "Directory:", getFieldEditorParent() );
-        dirEditor.getTextControl( getFieldEditorParent() ).addModifyListener( new ModifyListener()
-        {
-            public void modifyText( ModifyEvent e )
+        dirEditor = new DirectoryFieldEditor("dir", "Directory:", getFieldEditorParent());
+        dirEditor.getTextControl(getFieldEditorParent()).addModifyListener(
+            new ModifyListener()
             {
-                checkPageComplete();
-            }
-        } );
+                public void modifyText(ModifyEvent e)
+                {
+                    checkPageComplete();
+                }
+            });
 
-        addField( dirEditor );
-        addField( new BooleanFieldEditor( "recurse", "Recurse:", getFieldEditorParent() ) );
+        addField(dirEditor);
+        addField(new BooleanFieldEditor("recurse", "Recurse:", getFieldEditorParent()));
     }
 
-
     @Override
     protected void checkPageComplete()
     {
         super.checkPageComplete();
-        if ( isPageComplete() )
+        if (isPageComplete())
         {
-            setPageComplete( dirEditor.getStringValue().length() > 0 );
-            if ( isPageComplete() )
+            setPageComplete(dirEditor.getStringValue().length() > 0);
+            if (isPageComplete())
             {
-                if ( new File( dirEditor.getStringValue() ).isDirectory() )
+                if (new File(dirEditor.getStringValue()).isDirectory())
                 {
-                    setPageComplete( true );
-                    setErrorMessage( null );
+                    setPageComplete(true);
+                    setErrorMessage(null);
                 }
                 else
                 {
-                    setPageComplete( false );
-                    setErrorMessage( "Invalid directory" );
+                    setPageComplete(false);
+                    setErrorMessage("Invalid directory");
                 }
             }
         }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizard.java
index acd1434..0afef2e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizard.java
@@ -19,15 +19,13 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.repository;
 
-
 import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizard;
 
-
 public class OSGiInstallRepositoryWizard extends RepositoryWizard
 {
     @Override
     public void addPages()
     {
-        addPage( new OSGiInstallRepositoryWizardPage( this ) );
+        addPage(new OSGiInstallRepositoryWizardPage(this));
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizardPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizardPage.java
index ca142fc..83a1f96 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizardPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizardPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.repository;
 
-
 import java.util.ArrayList;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
@@ -28,31 +27,29 @@
 import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizardPage;
 import org.eclipse.jface.preference.RadioGroupFieldEditor;
 
-
 public class OSGiInstallRepositoryWizardPage extends RepositoryWizardPage
 {
 
-    protected OSGiInstallRepositoryWizardPage( RepositoryWizard parent )
+    protected OSGiInstallRepositoryWizardPage(RepositoryWizard parent)
     {
-        super( "OSGi Install Repository", parent );
+        super("OSGi Install Repository", parent);
     }
 
-
     @Override
     public void createFieldEditors()
     {
         ArrayList<String[]> installs = new ArrayList<String[]>();
-        for ( String id : SigilCore.getInstallManager().getInstallIDs() )
+        for (String id : SigilCore.getInstallManager().getInstallIDs())
         {
-            IOSGiInstall i = SigilCore.getInstallManager().findInstall( id );
-            installs.add( new String[]
-                { i.getType().getName(), id } );
+            IOSGiInstall i = SigilCore.getInstallManager().findInstall(id);
+            installs.add(new String[] { i.getType().getName(), id });
         }
-        String[][] strs = installs.toArray( new String[installs.size()][] );
+        String[][] strs = installs.toArray(new String[installs.size()][]);
 
-        RadioGroupFieldEditor editor = new RadioGroupFieldEditor( "id", "Install", 1, strs, getFieldEditorParent() );
+        RadioGroupFieldEditor editor = new RadioGroupFieldEditor("id", "Install", 1,
+            strs, getFieldEditorParent());
 
-        addField( editor );
+        addField(editor);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/startup/SigilStartup.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/startup/SigilStartup.java
index 595874a..d29655d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/startup/SigilStartup.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/startup/SigilStartup.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.startup;
 
-
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.felix.sigil.common.repository.IRepositoryChangeListener;
@@ -35,43 +34,47 @@
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.ui.IStartup;
 
-
 public class SigilStartup implements IStartup
 {
 
     public void earlyStartup()
     {
         final AtomicInteger updateCounter = new AtomicInteger();
-        
+
         // Register a repository change listener to re-run the resolver when repository changes
-        SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener( new IRepositoryChangeListener()
-        {
-            public void repositoryChanged( RepositoryChangeEvent event )
+        SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener(
+            new IRepositoryChangeListener()
             {
-                if ( !SigilUI.WORKSPACE_REPOSITORY_ID.equals( event.getRepository().getId() ) ) {
-                    final int update = updateCounter.incrementAndGet();
-                    
-                    Job job = new Job("Pending repository update") {
-                        @Override
-                        protected IStatus run(IProgressMonitor monitor)
+                public void repositoryChanged(RepositoryChangeEvent event)
+                {
+                    if (!SigilUI.WORKSPACE_REPOSITORY_ID.equals(event.getRepository().getId()))
+                    {
+                        final int update = updateCounter.incrementAndGet();
+
+                        Job job = new Job("Pending repository update")
                         {
-                            if ( update == updateCounter.get() ) {
-                                IWorkspace workspace = ResourcesPlugin.getWorkspace();
-                                ResolveProjectsJob job = new ResolveProjectsJob( workspace );
-                                job.setSystem( true );
-                                job.schedule();
+                            @Override
+                            protected IStatus run(IProgressMonitor monitor)
+                            {
+                                if (update == updateCounter.get())
+                                {
+                                    IWorkspace workspace = ResourcesPlugin.getWorkspace();
+                                    ResolveProjectsJob job = new ResolveProjectsJob(
+                                        workspace);
+                                    job.setSystem(true);
+                                    job.schedule();
+                                }
+                                return Status.OK_STATUS;
                             }
-                            return Status.OK_STATUS;
-                        }
-                        
-                    };
-                    job.setSystem(true);
-                    job.schedule(100);
-                } 
-                //else {
-                //   Repository changes are handled by ProjectResourceListener 
-                //}
-            }
-        } );
+
+                        };
+                        job.setSystem(true);
+                        job.schedule(100);
+                    }
+                    //else {
+                    //   Repository changes are handled by ProjectResourceListener 
+                    //}
+                }
+            });
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/ModelElementComparator.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/ModelElementComparator.java
index e170fc9..f1a3c70 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/ModelElementComparator.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/ModelElementComparator.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views;
 
-
 import org.apache.felix.sigil.common.model.osgi.IPackageExport;
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
@@ -29,7 +28,6 @@
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
 
-
 public class ModelElementComparator extends ViewerComparator
 {
     private static final int EXPORT_GROUP = 0;
@@ -37,18 +35,17 @@
     private static final int REQUIRE_GROUP = 2;
     private static final int OTHER_GROUP = 4;
 
-
-    public int category( Object element )
+    public int category(Object element)
     {
-        if ( element instanceof IPackageImport )
+        if (element instanceof IPackageImport)
         {
             return IMPORT_GROUP;
         }
-        else if ( element instanceof IPackageExport )
+        else if (element instanceof IPackageExport)
         {
             return EXPORT_GROUP;
         }
-        else if ( element instanceof IRequiredBundle )
+        else if (element instanceof IRequiredBundle)
         {
             return REQUIRE_GROUP;
         }
@@ -58,37 +55,36 @@
         }
     }
 
-
     @SuppressWarnings("unchecked")
     @Override
-    public int compare( Viewer viewer, Object e1, Object e2 )
+    public int compare(Viewer viewer, Object e1, Object e2)
     {
-        int cat1 = category( e1 );
-        int cat2 = category( e2 );
+        int cat1 = category(e1);
+        int cat2 = category(e2);
 
-        if ( cat1 != cat2 )
+        if (cat1 != cat2)
         {
             return cat1 - cat2;
         }
 
-        if ( cat1 == OTHER_GROUP )
+        if (cat1 == OTHER_GROUP)
         {
             String name1;
             String name2;
 
-            if ( viewer == null || !( viewer instanceof ContentViewer ) )
+            if (viewer == null || !(viewer instanceof ContentViewer))
             {
                 name1 = e1.toString();
                 name2 = e2.toString();
             }
             else
             {
-                IBaseLabelProvider prov = ( ( ContentViewer ) viewer ).getLabelProvider();
-                if ( prov instanceof ILabelProvider )
+                IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
+                if (prov instanceof ILabelProvider)
                 {
-                    ILabelProvider lprov = ( ILabelProvider ) prov;
-                    name1 = lprov.getText( e1 );
-                    name2 = lprov.getText( e2 );
+                    ILabelProvider lprov = (ILabelProvider) prov;
+                    name1 = lprov.getText(e1);
+                    name2 = lprov.getText(e2);
                 }
                 else
                 {
@@ -96,23 +92,23 @@
                     name2 = e2.toString();
                 }
             }
-            if ( name1 == null )
+            if (name1 == null)
             {
                 name1 = "";//$NON-NLS-1$
             }
-            if ( name2 == null )
+            if (name2 == null)
             {
                 name2 = "";//$NON-NLS-1$
             }
 
             // use the comparator to compare the strings
-            return getComparator().compare( name1, name2 );
+            return getComparator().compare(name1, name2);
         }
         else
         {
-            Comparable c1 = ( Comparable ) e1;
-            Comparable c2 = ( Comparable ) e2;
-            return c1.compareTo( c2 );
+            Comparable c1 = (Comparable) e1;
+            Comparable c2 = (Comparable) e2;
+            return c1.compareTo(c2);
         }
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
index 6b7acc8..9a831c0 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views;
 
-
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
@@ -61,7 +60,6 @@
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.ViewPart;
 
-
 public class RepositoryViewPart extends ViewPart implements IRepositoryChangeListener
 {
 
@@ -73,35 +71,35 @@
             return "Find Uses";
         }
 
-
         @Override
         public void run()
         {
             ISelection s = treeViewer.getSelection();
-            if ( !s.isEmpty() )
+            if (!s.isEmpty())
             {
-                IStructuredSelection sel = ( IStructuredSelection ) s;
-                IModelElement e = ( IModelElement ) sel.getFirstElement();
-                List<IModelElement> users = ModelHelper.findUsers( e );
+                IStructuredSelection sel = (IStructuredSelection) s;
+                IModelElement e = (IModelElement) sel.getFirstElement();
+                List<IModelElement> users = ModelHelper.findUsers(e);
                 String msg = null;
-                if ( users.isEmpty() )
+                if (users.isEmpty())
                 {
                     msg = "No users of " + e;
                 }
                 else
                 {
                     StringBuilder b = new StringBuilder();
-                    for ( IModelElement u : users )
+                    for (IModelElement u : users)
                     {
-                        ISigilBundle bndl = u.getAncestor( ISigilBundle.class );
-                        b.append( bndl );
-                        b.append( "->" );
-                        b.append( u );
-                        b.append( "\n" );
+                        ISigilBundle bndl = u.getAncestor(ISigilBundle.class);
+                        b.append(bndl);
+                        b.append("->");
+                        b.append(u);
+                        b.append("\n");
                     }
                     msg = b.toString();
                 }
-                MessageDialog.openInformation( getViewSite().getShell(), "Information", msg );
+                MessageDialog.openInformation(getViewSite().getShell(), "Information",
+                    msg);
             }
         }
     }
@@ -111,45 +109,43 @@
         final IBundleRepository rep;
         final IRepositoryModel model;
 
-
-        public RepositoryAction( IBundleRepository rep )
+        public RepositoryAction(IBundleRepository rep)
         {
             this.rep = rep;
-            this.model = SigilCore.getRepositoryConfiguration().findRepository( rep.getId() );
+            this.model = SigilCore.getRepositoryConfiguration().findRepository(
+                rep.getId());
         }
 
-
         @Override
         public void run()
         {
-            treeViewer.setInput( rep );
+            treeViewer.setInput(rep);
             createMenu();
         }
 
-
         @Override
         public String getText()
         {
             String name = model.getName();
-            if ( treeViewer.getInput() == rep )
+            if (treeViewer.getInput() == rep)
             {
                 name = "> " + name;
             }
             return name;
         }
 
-
         @Override
         public ImageDescriptor getImageDescriptor()
         {
             Image img = model.getType().getIcon();
-            if ( img == null )
+            if (img == null)
             {
-                return ImageDescriptor.createFromFile( RepositoryViewPart.class, "/icons/repository.gif" );
+                return ImageDescriptor.createFromFile(RepositoryViewPart.class,
+                    "/icons/repository.gif");
             }
             else
             {
-                return ImageDescriptor.createFromImage( img );
+                return ImageDescriptor.createFromImage(img);
             }
         }
     }
@@ -162,78 +158,72 @@
             treeViewer.collapseAll();
         }
 
-
         @Override
         public String getText()
         {
             return "Collapse All";
         }
 
-
         @Override
         public ImageDescriptor getImageDescriptor()
         {
-            return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL);
+            return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
+                ISharedImages.IMG_ELCL_COLLAPSEALL);
         }
     }
-    
+
     class RefreshAction extends Action
     {
         @Override
         public void run()
         {
-            IBundleRepository rep = ( IBundleRepository ) treeViewer.getInput();
-            if ( rep != null )
+            IBundleRepository rep = (IBundleRepository) treeViewer.getInput();
+            if (rep != null)
             {
                 rep.refresh();
                 treeViewer.refresh();
             }
         }
 
-
         @Override
         public String getText()
         {
             return "Refresh";
         }
 
-
         @Override
         public ImageDescriptor getImageDescriptor()
         {
-            
-            return ImageDescriptor.createFromFile( RepositoryViewPart.class, "/icons/bundle-refresh.gif" );
+
+            return ImageDescriptor.createFromFile(RepositoryViewPart.class,
+                "/icons/bundle-refresh.gif");
         }
 
     }
 
     private TreeViewer treeViewer;
 
-
     @Override
-    public void createPartControl( Composite parent )
+    public void createPartControl(Composite parent)
     {
-        createBody( parent );
+        createBody(parent);
         createMenu();
-        SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener( this );
+        SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener(this);
     }
 
-
     @Override
     public void dispose()
     {
-        SigilCore.getGlobalRepositoryManager().removeRepositoryChangeListener( this );
+        SigilCore.getGlobalRepositoryManager().removeRepositoryChangeListener(this);
         super.dispose();
     }
 
-
     private void createMenu()
     {
         createTopMenu();
         createLocalMenu();
     }
 
-
     private void createLocalMenu()
     {
         /*MenuManager menuMgr = new MenuManager();
@@ -244,183 +234,174 @@
         getViewSite().registerContextMenu(menuMgr, treeViewer); */
         IActionBars bars = getViewSite().getActionBars();
         IToolBarManager toolBar = bars.getToolBarManager();
-        toolBar.add( new RefreshAction() );
-        toolBar.add( new CollapseAction() );
+        toolBar.add(new RefreshAction());
+        toolBar.add(new CollapseAction());
     }
 
-
     private void createTopMenu()
     {
         IActionBars bars = getViewSite().getActionBars();
         IMenuManager menu = bars.getMenuManager();
         menu.removeAll();
-        for ( final IBundleRepository rep : SigilCore.getGlobalRepositoryManager().getRepositories() )
+        for (final IBundleRepository rep : SigilCore.getGlobalRepositoryManager().getRepositories())
         {
-            if ( treeViewer.getInput() == null )
+            if (treeViewer.getInput() == null)
             {
-                treeViewer.setInput( rep );
+                treeViewer.setInput(rep);
             }
 
-            RepositoryAction action = new RepositoryAction( rep );
-            menu.add( action );
+            RepositoryAction action = new RepositoryAction(rep);
+            menu.add(action);
         }
     }
 
-
-    private void createBody( Composite parent )
+    private void createBody(Composite parent)
     {
         // components
-        Composite control = new Composite( parent, SWT.NONE );
-        Tree tree = new Tree( control, SWT.NONE );
+        Composite control = new Composite(parent, SWT.NONE);
+        Tree tree = new Tree(control, SWT.NONE);
 
         // layout
-        control.setLayout( new GridLayout( 1, false ) );
-        tree.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 1 ) );
+        control.setLayout(new GridLayout(1, false));
+        tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
 
         // viewer
-        treeViewer = new TreeViewer( tree );
-        treeViewer.setContentProvider( new DefaultTreeContentProvider()
+        treeViewer = new TreeViewer(tree);
+        treeViewer.setContentProvider(new DefaultTreeContentProvider()
         {
-            public Object[] getChildren( Object parentElement )
+            public Object[] getChildren(Object parentElement)
             {
-                if ( parentElement instanceof ICompoundModelElement )
+                if (parentElement instanceof ICompoundModelElement)
                 {
-                    ICompoundModelElement model = ( ICompoundModelElement ) parentElement;
+                    ICompoundModelElement model = (ICompoundModelElement) parentElement;
                     return model.children();
                 }
 
                 return null;
             }
 
-
-            public Object getParent( Object element )
+            public Object getParent(Object element)
             {
-                if ( element instanceof IModelElement )
+                if (element instanceof IModelElement)
                 {
-                    IModelElement model = ( IModelElement ) element;
+                    IModelElement model = (IModelElement) element;
                     return model.getParent();
                 }
 
                 return null;
             }
 
-
-            public boolean hasChildren( Object element )
+            public boolean hasChildren(Object element)
             {
-                if ( element instanceof ICompoundModelElement )
+                if (element instanceof ICompoundModelElement)
                 {
-                    ICompoundModelElement model = ( ICompoundModelElement ) element;
+                    ICompoundModelElement model = (ICompoundModelElement) element;
                     return model.children().length > 0;
                 }
                 return false;
             }
 
-
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                IBundleRepository rep = ( IBundleRepository ) inputElement;
-                return getBundles( rep );
+                IBundleRepository rep = (IBundleRepository) inputElement;
+                return getBundles(rep);
             }
-        } );
+        });
 
-        treeViewer.setComparator( new ModelElementComparator() );
+        treeViewer.setComparator(new ModelElementComparator());
 
-        treeViewer.setLabelProvider( new ModelLabelProvider() );
+        treeViewer.setLabelProvider(new ModelLabelProvider());
 
-        treeViewer.addDragSupport( DND.DROP_LINK, new Transfer[]
-            { LocalSelectionTransfer.getTransfer() }, new DragSourceAdapter()
-        {
-            @Override
-            public void dragFinished( DragSourceEvent event )
+        treeViewer.addDragSupport(DND.DROP_LINK,
+            new Transfer[] { LocalSelectionTransfer.getTransfer() },
+            new DragSourceAdapter()
             {
-                // TODO Auto-generated method stub
-                super.dragFinished( event );
-            }
-
-
-            @Override
-            public void dragSetData( DragSourceEvent event )
-            {
-                // TODO Auto-generated method stub
-                super.dragSetData( event );
-            }
-
-
-            @SuppressWarnings("unchecked")
-            @Override
-            public void dragStart( DragSourceEvent event )
-            {
-                if ( treeViewer.getSelection().isEmpty() )
+                @Override
+                public void dragFinished(DragSourceEvent event)
                 {
-                    IStructuredSelection sel = ( IStructuredSelection ) treeViewer.getSelection();
-                    for ( Iterator<IModelElement> i = sel.iterator(); i.hasNext(); )
+                    // TODO Auto-generated method stub
+                    super.dragFinished(event);
+                }
+
+                @Override
+                public void dragSetData(DragSourceEvent event)
+                {
+                    // TODO Auto-generated method stub
+                    super.dragSetData(event);
+                }
+
+                @SuppressWarnings("unchecked")
+                @Override
+                public void dragStart(DragSourceEvent event)
+                {
+                    if (treeViewer.getSelection().isEmpty())
                     {
-                        IModelElement e = i.next();
-                        if ( e instanceof ISigilBundle )
+                        IStructuredSelection sel = (IStructuredSelection) treeViewer.getSelection();
+                        for (Iterator<IModelElement> i = sel.iterator(); i.hasNext();)
                         {
-                            event.data = e;
-                        }
-                        else
-                        {
-                            event.doit = false;
+                            IModelElement e = i.next();
+                            if (e instanceof ISigilBundle)
+                            {
+                                event.data = e;
+                            }
+                            else
+                            {
+                                event.doit = false;
+                            }
                         }
                     }
+                    else
+                    {
+                        event.doit = false;
+                    }
                 }
-                else
-                {
-                    event.doit = false;
-                }
-            }
-        } );
+            });
     }
 
-
     @Override
     public void setFocus()
     {
     }
 
-
-    public void repositoryChanged( RepositoryChangeEvent event )
+    public void repositoryChanged(RepositoryChangeEvent event)
     {
-        switch ( event.getType() )
+        switch (event.getType())
         {
             case ADDED:
                 createTopMenu();
                 break;
             case CHANGED:
-                if ( event.getRepository() == treeViewer.getInput() )
+                if (event.getRepository() == treeViewer.getInput())
                 {
-                    SigilUI.runInUI( new Runnable()
+                    SigilUI.runInUI(new Runnable()
                     {
                         public void run()
                         {
                             treeViewer.refresh();
                         }
-                    } );
+                    });
                 }
                 break;
             case REMOVED:
-                if ( event.getRepository() == treeViewer.getInput() )
+                if (event.getRepository() == treeViewer.getInput())
                 {
-                    treeViewer.setInput( null );
+                    treeViewer.setInput(null);
                 }
                 createTopMenu();
         }
     }
 
-
-    private Object[] getBundles( IBundleRepository repository )
+    private Object[] getBundles(IBundleRepository repository)
     {
         final LinkedList<ISigilBundle> bundles = new LinkedList<ISigilBundle>();
-        repository.accept( new IRepositoryVisitor()
+        repository.accept(new IRepositoryVisitor()
         {
-            public boolean visit( ISigilBundle bundle )
+            public boolean visit(ISigilBundle bundle)
             {
-                bundles.add( bundle );
+                bundles.add(bundle);
                 return true;
             }
-        } );
+        });
         return bundles.toArray();
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleConnectionHighlighter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleConnectionHighlighter.java
index 07157b2..0f32001 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleConnectionHighlighter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleConnectionHighlighter.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
 
-
 import java.util.Set;
 
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
@@ -32,45 +31,42 @@
 import org.eclipse.zest.core.widgets.GraphItem;
 import org.eclipse.zest.core.widgets.GraphNode;
 
-
 public class BundleConnectionHighlighter implements ISelectionChangedListener
 {
 
     private BundleResolverView view;
 
-
-    public BundleConnectionHighlighter( BundleResolverView view )
+    public BundleConnectionHighlighter(BundleResolverView view)
     {
         this.view = view;
     }
 
-
-    public void selectionChanged( SelectionChangedEvent event )
+    public void selectionChanged(SelectionChangedEvent event)
     {
         ISelection selection = event.getSelection();
-        if ( !selection.isEmpty() )
+        if (!selection.isEmpty())
         {
-            IStructuredSelection str = ( IStructuredSelection ) selection;
+            IStructuredSelection str = (IStructuredSelection) selection;
 
             Object sel = str.getFirstElement();
 
-            if ( sel instanceof ISigilBundle )
+            if (sel instanceof ISigilBundle)
             {
-                BundleGraph graph = ( BundleGraph ) view.getBundlegraph();
+                BundleGraph graph = (BundleGraph) view.getBundlegraph();
 
-                ISigilBundle selected = ( ISigilBundle ) sel;
-                Set<ISigilBundle> connected = graph.getTargets( selected );
+                ISigilBundle selected = (ISigilBundle) sel;
+                Set<ISigilBundle> connected = graph.getTargets(selected);
 
-                highlightLinks( graph, selected, connected );
-                highlightBundles( graph, selected, connected );
+                highlightLinks(graph, selected, connected);
+                highlightBundles(graph, selected, connected);
             }
-            else if ( sel instanceof Link )
+            else if (sel instanceof Link)
             {
-                GraphConnection c = ( GraphConnection ) findGraphItem( sel );
-                if ( c != null )
+                GraphConnection c = (GraphConnection) findGraphItem(sel);
+                if (c != null)
                 {
                     c.unhighlight();
-                    c.setHighlightColor( ColorConstants.blue );
+                    c.setHighlightColor(ColorConstants.blue);
                     c.highlight();
                 }
             }
@@ -81,26 +77,26 @@
         }
     }
 
-
-    private void highlightBundles( BundleGraph graph, ISigilBundle selected, Set<ISigilBundle> connected )
+    private void highlightBundles(BundleGraph graph, ISigilBundle selected,
+        Set<ISigilBundle> connected)
     {
-        for ( ISigilBundle bundle : graph.getBundles() )
+        for (ISigilBundle bundle : graph.getBundles())
         {
-            GraphNode node = ( GraphNode ) findGraphItem( bundle );
-            if ( node != null )
+            GraphNode node = (GraphNode) findGraphItem(bundle);
+            if (node != null)
             {
                 node.unhighlight();
 
-                if ( bundle == selected )
+                if (bundle == selected)
                 {
-                    node.setHighlightColor( ColorConstants.yellow );
+                    node.setHighlightColor(ColorConstants.yellow);
                     node.highlight();
                 }
-                else if ( view.isDisplayed( BundleResolverView.DEPENDENTS ) )
+                else if (view.isDisplayed(BundleResolverView.DEPENDENTS))
                 {
-                    if ( connected.contains( bundle ) )
+                    if (connected.contains(bundle))
                     {
-                        node.setHighlightColor( ColorConstants.lightBlue );
+                        node.setHighlightColor(ColorConstants.lightBlue);
                         node.highlight();
                     }
                 }
@@ -108,21 +104,21 @@
         }
     }
 
-
-    private void highlightLinks( BundleGraph graph, ISigilBundle selected, Set<ISigilBundle> connected )
+    private void highlightLinks(BundleGraph graph, ISigilBundle selected,
+        Set<ISigilBundle> connected)
     {
-        for ( Link l : graph.getLinks() )
+        for (Link l : graph.getLinks())
         {
-            GraphConnection c = ( GraphConnection ) findGraphItem( l );
-            if ( c != null )
+            GraphConnection c = (GraphConnection) findGraphItem(l);
+            if (c != null)
             {
                 c.unhighlight();
 
-                if ( view.isDisplayed( BundleResolverView.DEPENDENTS ) )
+                if (view.isDisplayed(BundleResolverView.DEPENDENTS))
                 {
-                    if ( l.getSource() == selected && connected.contains( l.getTarget() ) )
+                    if (l.getSource() == selected && connected.contains(l.getTarget()))
                     {
-                        c.setHighlightColor( ColorConstants.lightBlue );
+                        c.setHighlightColor(ColorConstants.lightBlue);
                         c.highlight();
                     }
                 }
@@ -130,14 +126,13 @@
         }
     }
 
-
-    private GraphItem findGraphItem( Object l )
+    private GraphItem findGraphItem(Object l)
     {
         try
         {
-            return view.getGraphViewer().findGraphItem( l );
+            return view.getGraphViewer().findGraphItem(l);
         }
-        catch ( ArrayIndexOutOfBoundsException e )
+        catch (ArrayIndexOutOfBoundsException e)
         {
             // temporary fix for issue 
             // https://bugs.eclipse.org/bugs/show_bug.cgi?id=242523
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraph.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraph.java
index ae28f96..fc8562d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraph.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraph.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
 
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -31,7 +30,6 @@
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 
-
 public class BundleGraph
 {
 
@@ -39,89 +37,82 @@
     private LinkedList<Link> links = new LinkedList<Link>();
     private HashSet<ISigilBundle> bundles = new HashSet<ISigilBundle>();
 
-
-    public void startResolution( IModelElement requirement )
+    public void startResolution(IModelElement requirement)
     {
     }
 
-
-    public void endResolution( IModelElement requirement, ISigilBundle target )
+    public void endResolution(IModelElement requirement, ISigilBundle target)
     {
-        ISigilBundle source = requirement.getAncestor( ISigilBundle.class );
+        ISigilBundle source = requirement.getAncestor(ISigilBundle.class);
 
-        bundles.add( source );
-        bundles.add( target );
+        bundles.add(source);
+        bundles.add(target);
 
-        LinkedList<Link> links = lookup.get( source );
+        LinkedList<Link> links = lookup.get(source);
 
-        if ( links == null )
+        if (links == null)
         {
             links = new LinkedList<Link>();
-            lookup.put( source, links );
+            lookup.put(source, links);
         }
 
         Link l = null;
-        for ( Link c : links )
+        for (Link c : links)
         {
-            if ( c.getTarget() == target )
+            if (c.getTarget() == target)
             {
                 l = c;
                 break;
             }
         }
 
-        if ( l == null )
+        if (l == null)
         {
-            l = new Link( source, target );
-            links.add( l );
-            this.links.add( l );
+            l = new Link(source, target);
+            links.add(l);
+            this.links.add(l);
         }
 
-        l.addRequirement( requirement );
+        l.addRequirement(requirement);
     }
 
-
     public List<Link> getLinks()
     {
         return links;
     }
 
-
     public Set<ISigilBundle> getBundles()
     {
         return bundles;
     }
 
-
-    public Set<ISigilBundle> getTargets( ISigilBundle bundle )
+    public Set<ISigilBundle> getTargets(ISigilBundle bundle)
     {
         HashSet<ISigilBundle> targets = new HashSet<ISigilBundle>();
 
-        for ( Link l : getLinks( bundle ) )
+        for (Link l : getLinks(bundle))
         {
-            targets.add( l.getTarget() );
+            targets.add(l.getTarget());
         }
 
         return targets;
     }
 
-
-    public List<Link> getLinks( ISigilBundle selected )
+    public List<Link> getLinks(ISigilBundle selected)
     {
-        List<Link> l = lookup.get( selected );
+        List<Link> l = lookup.get(selected);
         return l == null ? Collections.<Link> emptyList() : l;
     }
 
-
-    public List<Link> getDependentLinks( ISigilBundle bundle )
+    public List<Link> getDependentLinks(ISigilBundle bundle)
     {
-        ArrayList<Link> found = new ArrayList<Link>( links.size() );
+        ArrayList<Link> found = new ArrayList<Link>(links.size());
 
-        for ( Link l : links )
+        for (Link l : links)
         {
-            if ( l.getTarget() == bundle )
+            if (l.getTarget() == bundle)
             {
-                found.add( l );
+                found.add(l);
             }
         }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphContentProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphContentProvider.java
index d0f9fff..345dcfd 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphContentProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphContentProvider.java
@@ -19,43 +19,37 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
 
-
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.zest.core.viewers.IGraphContentProvider;
 
-
 public class BundleGraphContentProvider implements IGraphContentProvider
 {
 
-    public Object[] getElements( Object input )
+    public Object[] getElements(Object input)
     {
-        BundleGraph graph = ( BundleGraph ) input;
+        BundleGraph graph = (BundleGraph) input;
         return graph.getLinks().toArray();
     }
 
-
-    public Object getDestination( Object element )
+    public Object getDestination(Object element)
     {
-        Link l = ( Link ) element;
+        Link l = (Link) element;
         return l.isSatisfied() ? l.getTarget() : new Link.Unsatisfied();
     }
 
-
-    public Object getSource( Object element )
+    public Object getSource(Object element)
     {
-        Link l = ( Link ) element;
+        Link l = (Link) element;
         return l.getSource();
     }
 
-
     public void dispose()
     {
         // TODO Auto-generated method stub
 
     }
 
-
-    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
     {
 
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphLabelProvider.java
index b93cf33..2e090bf 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphLabelProvider.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
 
-
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 import org.apache.felix.sigil.eclipse.ui.SigilUI;
 import org.eclipse.jface.viewers.LabelProvider;
@@ -27,30 +26,27 @@
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
 
-
 public class BundleGraphLabelProvider extends LabelProvider
 {
 
     private BundleResolverView view;
 
-
-    public BundleGraphLabelProvider( BundleResolverView view )
+    public BundleGraphLabelProvider(BundleResolverView view)
     {
         this.view = view;
     }
 
-
     @Override
-    public String getText( Object element )
+    public String getText(Object element)
     {
-        if ( element instanceof Link )
+        if (element instanceof Link)
         {
-            Link l = ( Link ) element;
-            if ( l.isSatisfied() )
+            Link l = (Link) element;
+            if (l.isSatisfied())
             {
-                if ( view.isDisplayed( BundleResolverView.LINK_LABELS ) )
+                if (view.isDisplayed(BundleResolverView.LINK_LABELS))
                 {
-                    return view.getLinkText( ( Link ) element );
+                    return view.getLinkText((Link) element);
                 }
                 else
                 {
@@ -59,15 +55,16 @@
             }
             else
             {
-                return view.getLinkText( ( Link ) element );
+                return view.getLinkText((Link) element);
             }
         }
-        else if ( element instanceof ISigilBundle )
+        else if (element instanceof ISigilBundle)
         {
-            ISigilBundle b = ( ISigilBundle ) element;
-            return b.getBundleInfo().getSymbolicName() + ": " + b.getBundleInfo().getVersion();
+            ISigilBundle b = (ISigilBundle) element;
+            return b.getBundleInfo().getSymbolicName() + ": "
+                + b.getBundleInfo().getVersion();
         }
-        else if ( element instanceof Link.Unsatisfied )
+        else if (element instanceof Link.Unsatisfied)
         {
             return "unsatisfied";
         }
@@ -77,18 +74,19 @@
         }
     }
 
-
     @Override
-    public Image getImage( Object element )
+    public Image getImage(Object element)
     {
         Image result = null;
-        if ( element instanceof ISigilBundle )
+        if (element instanceof ISigilBundle)
         {
-            result = SigilUI.cacheImage( "icons/bundle.gif", BundleGraphLabelProvider.class.getClassLoader() );
+            result = SigilUI.cacheImage("icons/bundle.gif",
+                BundleGraphLabelProvider.class.getClassLoader());
         }
-        else if ( element instanceof Link.Unsatisfied )
+        else if (element instanceof Link.Unsatisfied)
         {
-            return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+            return PlatformUI.getWorkbench().getSharedImages().getImage(
+                ISharedImages.IMG_OBJS_ERROR_TSK);
         }
 
         return result;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphViewFilter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphViewFilter.java
index 9396e4a..353c5bb 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphViewFilter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphViewFilter.java
@@ -19,48 +19,44 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
 
-
 import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerFilter;
 
-
 public class BundleGraphViewFilter extends ViewerFilter
 {
 
     private BundleResolverView view;
 
-
-    public BundleGraphViewFilter( BundleResolverView view )
+    public BundleGraphViewFilter(BundleResolverView view)
     {
         this.view = view;
     }
 
-
     @Override
-    public boolean select( Viewer viewer, Object parentElement, Object element )
+    public boolean select(Viewer viewer, Object parentElement, Object element)
     {
-        if ( !view.isDisplayed( BundleResolverView.LOCAL_LINKS ) )
+        if (!view.isDisplayed(BundleResolverView.LOCAL_LINKS))
         {
-            if ( element instanceof Link )
+            if (element instanceof Link)
             {
-                Link l = ( Link ) element;
+                Link l = (Link) element;
                 return l.getSource() != l.getTarget();
             }
         }
-        if ( !view.isDisplayed( BundleResolverView.SATISFIED ) )
+        if (!view.isDisplayed(BundleResolverView.SATISFIED))
         {
-            if ( element instanceof Link )
+            if (element instanceof Link)
             {
-                Link l = ( Link ) element;
+                Link l = (Link) element;
                 return !l.isSatisfied();
             }
-            else if ( element instanceof ISigilBundle )
+            else if (element instanceof ISigilBundle)
             {
-                ISigilBundle bundle = ( ISigilBundle ) element;
-                for ( Link l : view.getBundlegraph().getLinks( bundle ) )
+                ISigilBundle bundle = (ISigilBundle) element;
+                for (Link l : view.getBundlegraph().getLinks(bundle))
                 {
-                    if ( !l.isSatisfied() )
+                    if (!l.isSatisfied())
                     {
                         return true;
                     }
@@ -69,14 +65,14 @@
             }
         }
 
-        if ( !view.isDisplayed( BundleResolverView.UNSATISFIED ) )
+        if (!view.isDisplayed(BundleResolverView.UNSATISFIED))
         {
-            if ( element instanceof Link )
+            if (element instanceof Link)
             {
-                Link l = ( Link ) element;
+                Link l = (Link) element;
                 return l.isSatisfied();
             }
-            else if ( element instanceof Link.Unsatisfied )
+            else if (element instanceof Link.Unsatisfied)
             {
                 return false;
             }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleResolverView.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleResolverView.java
index 2da1a51..8cf101a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleResolverView.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleResolverView.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
 
-
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -60,7 +59,6 @@
 import org.eclipse.zest.layouts.algorithms.RadialLayoutAlgorithm;
 import org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm;
 
-
 public class BundleResolverView extends ViewPart
 {
 
@@ -98,149 +96,140 @@
         private String showMsg;
         private String hideMsg;
 
-
-        ToggleDisplayAction( String key, String showMsg, String hideMsg )
+        ToggleDisplayAction(String key, String showMsg, String hideMsg)
         {
             this.key = key;
             this.showMsg = showMsg;
             this.hideMsg = hideMsg;
-            setText( BundleResolverView.this.isDisplayed( key ) ? hideMsg : showMsg );
+            setText(BundleResolverView.this.isDisplayed(key) ? hideMsg : showMsg);
         }
 
-
         @Override
         public void run()
         {
-            BundleResolverView.this.setDisplayed( key, !BundleResolverView.this.isDisplayed( key ) );
-            setText( BundleResolverView.this.isDisplayed( key ) ? hideMsg : showMsg );
+            BundleResolverView.this.setDisplayed(key,
+                !BundleResolverView.this.isDisplayed(key));
+            setText(BundleResolverView.this.isDisplayed(key) ? hideMsg : showMsg);
         }
     }
 
-
-    public void setInput( final IModelElement element )
+    public void setInput(final IModelElement element)
     {
-        if ( current == null || !current.equals( element ) )
+        if (current == null || !current.equals(element))
         {
-            SigilCore.log( "Set input " + element );
+            SigilCore.log("Set input " + element);
             current = element;
             redraw();
         }
     }
 
-
-    public void setDisplayed( String key, boolean b )
+    public void setDisplayed(String key, boolean b)
     {
-        displayed.put( key, b );
+        displayed.put(key, b);
 
-        if ( key == DEPENDENTS )
+        if (key == DEPENDENTS)
         {
             int style = LayoutStyles.NO_LAYOUT_NODE_RESIZING;
-            viewer.setLayoutAlgorithm( b ? new TreeLayoutAlgorithm( style ) : new RadialLayoutAlgorithm( style ) );
+            viewer.setLayoutAlgorithm(b ? new TreeLayoutAlgorithm(style)
+                : new RadialLayoutAlgorithm(style));
             redraw();
         }
-        else if ( key == OPTIONAL )
+        else if (key == OPTIONAL)
         {
             redraw();
         }
-        else if ( key == SATISFIED || key == UNSATISFIED )
+        else if (key == SATISFIED || key == UNSATISFIED)
         {
             viewer.refresh();
         }
     }
 
-
-    public boolean isDisplayed( String key )
+    public boolean isDisplayed(String key)
     {
-        return displayed.get( key );
+        return displayed.get(key);
     }
 
-
     @Override
     public void setFocus()
     {
     }
 
-
     @Override
-    public void createPartControl( Composite parent )
+    public void createPartControl(Composite parent)
     {
         init();
-        createViewer( parent );
+        createViewer(parent);
         createListeners();
         createMenu();
     }
 
-
     private void init()
     {
-        displayed.put( LINK_LABELS, false );
-        displayed.put( LOCAL_LINKS, false );
-        displayed.put( DEPENDENTS, false );
-        displayed.put( OPTIONAL, false );
-        displayed.put( SATISFIED, true );
-        displayed.put( UNSATISFIED, true );
+        displayed.put(LINK_LABELS, false);
+        displayed.put(LOCAL_LINKS, false);
+        displayed.put(DEPENDENTS, false);
+        displayed.put(OPTIONAL, false);
+        displayed.put(SATISFIED, true);
+        displayed.put(UNSATISFIED, true);
     }
 
-
     public BundleGraph getBundlegraph()
     {
-        return ( BundleGraph ) viewer.getInput();
+        return (BundleGraph) viewer.getInput();
     }
 
-
     GraphViewer getGraphViewer()
     {
         return viewer;
     }
 
-
-    String getLinkText( Link link )
+    String getLinkText(Link link)
     {
         StringBuffer buf = new StringBuffer();
 
-        for ( IModelElement e : link.getRequirements() )
+        for (IModelElement e : link.getRequirements())
         {
-            if ( buf.length() > 0 )
+            if (buf.length() > 0)
             {
-                buf.append( "\n" );
+                buf.append("\n");
             }
-            if ( e instanceof IPackageImport )
+            if (e instanceof IPackageImport)
             {
-                IPackageImport pi = ( IPackageImport ) e;
-                buf.append( "import " + pi.getPackageName() + " : " + pi.getVersions() + ": "
-                    + ( pi.isOptional() ? "optional" : "mandatory" ) );
+                IPackageImport pi = (IPackageImport) e;
+                buf.append("import " + pi.getPackageName() + " : " + pi.getVersions()
+                    + ": " + (pi.isOptional() ? "optional" : "mandatory"));
             }
-            else if ( e instanceof IRequiredBundle )
+            else if (e instanceof IRequiredBundle)
             {
-                IRequiredBundle rb = ( IRequiredBundle ) e;
-                buf.append( "required bundle " + rb.getSymbolicName() + " : " + rb.getVersions() + ": "
-                    + ( rb.isOptional() ? "optional" : "mandatory" ) );
+                IRequiredBundle rb = (IRequiredBundle) e;
+                buf.append("required bundle " + rb.getSymbolicName() + " : "
+                    + rb.getVersions() + ": "
+                    + (rb.isOptional() ? "optional" : "mandatory"));
             }
         }
 
         return buf.toString();
     }
 
-
     private synchronized void redraw()
     {
         final IModelElement element = current;
-        if ( job != null )
+        if (job != null)
         {
             job.cancel();
         }
 
-        job = new Job( "Resolving " + current )
+        job = new Job("Resolving " + current)
         {
             @Override
-            protected IStatus run( IProgressMonitor progress )
+            protected IStatus run(IProgressMonitor progress)
             {
                 try
                 {
-                    resolve( element, progress );
+                    resolve(element, progress);
                     return Status.OK_STATUS;
                 }
-                catch ( CoreException e )
+                catch (CoreException e)
                 {
                     return e.getStatus();
                 }
@@ -249,151 +238,150 @@
         job.schedule();
     }
 
-
-    private void resolve( IModelElement element, IProgressMonitor progress ) throws CoreException
+    private void resolve(IModelElement element, IProgressMonitor progress)
+        throws CoreException
     {
         final BundleGraph graph = new BundleGraph();
 
-        IResolutionMonitor monitor = new ResolutionMonitorAdapter( progress )
+        IResolutionMonitor monitor = new ResolutionMonitorAdapter(progress)
         {
             @Override
-            public void startResolution( IModelElement requirement )
+            public void startResolution(IModelElement requirement)
             {
-                graph.startResolution( requirement );
+                graph.startResolution(requirement);
             }
 
-
             @Override
-            public void endResolution( IModelElement requirement, ISigilBundle provider )
+            public void endResolution(IModelElement requirement, ISigilBundle provider)
             {
-                graph.endResolution( requirement, provider );
+                graph.endResolution(requirement, provider);
             }
         };
 
-        ISigilProjectModel project = findProject( element );
-        IRepositoryManager repository = SigilCore.getRepositoryManager( project );
+        ISigilProjectModel project = findProject(element);
+        IRepositoryManager repository = SigilCore.getRepositoryManager(project);
 
         int options = ResolutionConfig.IGNORE_ERRORS;
 
-        if ( isDisplayed( DEPENDENTS ) )
+        if (isDisplayed(DEPENDENTS))
         {
             options |= ResolutionConfig.INCLUDE_DEPENDENTS;
         }
-        if ( isDisplayed( OPTIONAL ) )
+        if (isDisplayed(OPTIONAL))
         {
             options |= ResolutionConfig.INCLUDE_OPTIONAL;
         }
 
-        ResolutionConfig config = new ResolutionConfig( options );
+        ResolutionConfig config = new ResolutionConfig(options);
 
         try
         {
-            repository.getBundleResolver().resolve( element, config, monitor );
+            repository.getBundleResolver().resolve(element, config, monitor);
         }
-        catch ( ResolutionException e )
+        catch (ResolutionException e)
         {
-            throw SigilCore.newCoreException( "Failed to resolve " + element, e );
+            throw SigilCore.newCoreException("Failed to resolve " + element, e);
         }
 
-        SigilUI.runInUI( new Runnable()
+        SigilUI.runInUI(new Runnable()
         {
             public void run()
             {
-                viewer.setInput( graph );
+                viewer.setInput(graph);
                 addCustomUIElements();
             }
-        } );
+        });
     }
 
-
-    private static ISigilProjectModel findProject( IModelElement element )
+    private static ISigilProjectModel findProject(IModelElement element)
     {
-        if ( element == null )
+        if (element == null)
         {
             return null;
         }
-        if ( element instanceof ISigilProjectModel )
+        if (element instanceof ISigilProjectModel)
         {
-            return ( ISigilProjectModel ) element;
+            return (ISigilProjectModel) element;
         }
 
-        return element.getAncestor( ISigilProjectModel.class );
+        return element.getAncestor(ISigilProjectModel.class);
     }
 
-
     @SuppressWarnings("unchecked")
     private void addCustomUIElements()
     {
-        if ( !isDisplayed( LINK_LABELS ) )
+        if (!isDisplayed(LINK_LABELS))
         {
-            for ( GraphConnection c : ( List<GraphConnection> ) viewer.getGraphControl().getConnections() )
+            for (GraphConnection c : (List<GraphConnection>) viewer.getGraphControl().getConnections())
             {
-                if ( c.getData() instanceof Link )
+                if (c.getData() instanceof Link)
                 {
-                    c.setTooltip( buildToolTip( ( Link ) c.getData() ) );
+                    c.setTooltip(buildToolTip((Link) c.getData()));
                 }
             }
         }
     }
 
-
-    private IFigure buildToolTip( Link link )
+    private IFigure buildToolTip(Link link)
     {
         Label l = new Label();
-        l.setText( getLinkText( link ) );
+        l.setText(getLinkText(link));
         return l;
     }
 
-
-    private void createViewer( Composite parent )
+    private void createViewer(Composite parent)
     {
-        parent.setLayout( new FillLayout() );
-        viewer = new GraphViewer( parent, SWT.H_SCROLL | SWT.V_SCROLL );
+        parent.setLayout(new FillLayout());
+        viewer = new GraphViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
         IContentProvider contentProvider = new BundleGraphContentProvider();
-        viewer.setContentProvider( contentProvider );
-        viewer.setLabelProvider( new BundleGraphLabelProvider( this ) );
-        viewer.addFilter( new BundleGraphViewFilter( this ) );
+        viewer.setContentProvider(contentProvider);
+        viewer.setLabelProvider(new BundleGraphLabelProvider(this));
+        viewer.addFilter(new BundleGraphViewFilter(this));
 
         int style = LayoutStyles.NO_LAYOUT_NODE_RESIZING;
-        viewer.setLayoutAlgorithm( isDisplayed( DEPENDENTS ) ? new TreeLayoutAlgorithm( style )
-            : new RadialLayoutAlgorithm( style ) );
-        viewer.addSelectionChangedListener( new BundleConnectionHighlighter( this ) );
-        viewer.setInput( new BundleGraph() );
+        viewer.setLayoutAlgorithm(isDisplayed(DEPENDENTS) ? new TreeLayoutAlgorithm(style)
+            : new RadialLayoutAlgorithm(style));
+        viewer.addSelectionChangedListener(new BundleConnectionHighlighter(this));
+        viewer.setInput(new BundleGraph());
     }
 
-
     private void createMenu()
     {
         IActionBars action = getViewSite().getActionBars();
-        action.getMenuManager().add( new ToggleDisplayAction( LINK_LABELS, SHOW_LINK_LABELS, HIDE_LINK_LABELS ) );
-        action.getMenuManager().add( new ToggleDisplayAction( LOCAL_LINKS, SHOW_LOCAL_LINKS, HIDE_LOCAL_LINKS ) );
-        action.getMenuManager().add( new ToggleDisplayAction( DEPENDENTS, SHOW_DEPENDENTS, HIDE_DEPENDENTS ) );
-        action.getMenuManager().add( new ToggleDisplayAction( OPTIONAL, SHOW_OPTIONAL, HIDE_OPTIONAL ) );
-        action.getMenuManager().add( new ToggleDisplayAction( SATISFIED, SHOW_SATISFIED, HIDE_SATISFIED ) );
-        action.getMenuManager().add( new ToggleDisplayAction( UNSATISFIED, SHOW_UNSATISFIED, HIDE_UNSATISFIED ) );
+        action.getMenuManager().add(
+            new ToggleDisplayAction(LINK_LABELS, SHOW_LINK_LABELS, HIDE_LINK_LABELS));
+        action.getMenuManager().add(
+            new ToggleDisplayAction(LOCAL_LINKS, SHOW_LOCAL_LINKS, HIDE_LOCAL_LINKS));
+        action.getMenuManager().add(
+            new ToggleDisplayAction(DEPENDENTS, SHOW_DEPENDENTS, HIDE_DEPENDENTS));
+        action.getMenuManager().add(
+            new ToggleDisplayAction(OPTIONAL, SHOW_OPTIONAL, HIDE_OPTIONAL));
+        action.getMenuManager().add(
+            new ToggleDisplayAction(SATISFIED, SHOW_SATISFIED, HIDE_SATISFIED));
+        action.getMenuManager().add(
+            new ToggleDisplayAction(UNSATISFIED, SHOW_UNSATISFIED, HIDE_UNSATISFIED));
         action.updateActionBars();
     }
 
-
     private void createListeners()
     {
-        IPartService ps = ( IPartService ) getViewSite().getService( IPartService.class );
-        ps.addPartListener( new EditorViewPartListener( this ) );
-        viewer.getGraphControl().addControlListener( new ControlAdapter()
+        IPartService ps = (IPartService) getViewSite().getService(IPartService.class);
+        ps.addPartListener(new EditorViewPartListener(this));
+        viewer.getGraphControl().addControlListener(new ControlAdapter()
         {
             @Override
-            public void controlResized( ControlEvent e )
+            public void controlResized(ControlEvent e)
             {
-                Graph g = ( Graph ) e.getSource();
+                Graph g = (Graph) e.getSource();
                 int x = g.getSize().x;
                 int y = g.getSize().y;
-                if ( lastX != x || lastY != y )
+                if (lastX != x || lastY != y)
                 {
                     lastX = x;
                     lastY = y;
                     redraw();
                 }
             }
-        } );
+        });
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/EditorViewPartListener.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/EditorViewPartListener.java
index 3480193..32fc147 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/EditorViewPartListener.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/EditorViewPartListener.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.eclipse.core.resources.IProject;
@@ -30,86 +29,75 @@
 import org.eclipse.ui.IPartListener2;
 import org.eclipse.ui.IWorkbenchPartReference;
 
-
 public class EditorViewPartListener implements IPartListener2
 {
 
     private BundleResolverView bundleResolverView;
 
-
-    public EditorViewPartListener( BundleResolverView bundleResolverView )
+    public EditorViewPartListener(BundleResolverView bundleResolverView)
     {
         this.bundleResolverView = bundleResolverView;
     }
 
-
-    public void partActivated( IWorkbenchPartReference partRef )
+    public void partActivated(IWorkbenchPartReference partRef)
     {
-        checkRef( partRef );
+        checkRef(partRef);
     }
 
-
-    public void partBroughtToTop( IWorkbenchPartReference partRef )
+    public void partBroughtToTop(IWorkbenchPartReference partRef)
     {
         // no action
     }
 
-
-    public void partClosed( IWorkbenchPartReference partRef )
+    public void partClosed(IWorkbenchPartReference partRef)
     {
         // no action
     }
 
-
-    public void partDeactivated( IWorkbenchPartReference partRef )
+    public void partDeactivated(IWorkbenchPartReference partRef)
     {
         // no action
     }
 
-
-    public void partHidden( IWorkbenchPartReference partRef )
+    public void partHidden(IWorkbenchPartReference partRef)
     {
         // no action
     }
 
-
-    public void partInputChanged( IWorkbenchPartReference partRef )
+    public void partInputChanged(IWorkbenchPartReference partRef)
     {
         // no action
     }
 
-
-    public void partOpened( IWorkbenchPartReference partRef )
+    public void partOpened(IWorkbenchPartReference partRef)
     {
         // no action
     }
 
-
-    public void partVisible( IWorkbenchPartReference partRef )
+    public void partVisible(IWorkbenchPartReference partRef)
     {
         // no action
     }
 
-
-    private void checkRef( IWorkbenchPartReference partRef )
+    private void checkRef(IWorkbenchPartReference partRef)
     {
         IEditorPart editor = partRef.getPage().getActiveEditor();
-        if ( editor != null )
+        if (editor != null)
         {
             IEditorInput input = editor.getEditorInput();
-            if ( input instanceof IFileEditorInput )
+            if (input instanceof IFileEditorInput)
             {
-                IFileEditorInput f = ( IFileEditorInput ) input;
+                IFileEditorInput f = (IFileEditorInput) input;
                 IProject project = f.getFile().getProject();
                 try
                 {
-                    ISigilProjectModel model = SigilCore.create( project );
-                    if ( model != null )
+                    ISigilProjectModel model = SigilCore.create(project);
+                    if (model != null)
                     {
-                        bundleResolverView.setInput( model );
+                        bundleResolverView.setInput(model);
                     }
                 }
-                catch ( CoreException e )
+                catch (CoreException e)
                 {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/Link.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/Link.java
index b0c21fc..fe77cc4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/Link.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/Link.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
 
-
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.LinkedList;
@@ -30,7 +29,6 @@
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
 
-
 public class Link
 {
     public static class Unsatisfied
@@ -45,13 +43,13 @@
     private static final Comparator<IModelElement> comparator = new Comparator<IModelElement>()
     {
 
-        public int compare( IModelElement o1, IModelElement o2 )
+        public int compare(IModelElement o1, IModelElement o2)
         {
-            if ( o1 instanceof IRequiredBundle )
+            if (o1 instanceof IRequiredBundle)
             {
-                if ( o2 instanceof IRequiredBundle )
+                if (o2 instanceof IRequiredBundle)
                 {
-                    return compareBundles( ( IRequiredBundle ) o1, ( IRequiredBundle ) o2 );
+                    return compareBundles((IRequiredBundle) o1, (IRequiredBundle) o2);
                 }
                 else
                 {
@@ -60,25 +58,24 @@
             }
             else
             {
-                if ( o2 instanceof IRequiredBundle )
+                if (o2 instanceof IRequiredBundle)
                 {
                     return 1;
                 }
                 else
                 {
-                    return compareNonBundles( o1, o2 );
+                    return compareNonBundles(o1, o2);
                 }
             }
         }
 
-
-        private int compareNonBundles( IModelElement o1, IModelElement o2 )
+        private int compareNonBundles(IModelElement o1, IModelElement o2)
         {
-            if ( o1 instanceof IPackageImport )
+            if (o1 instanceof IPackageImport)
             {
-                if ( o2 instanceof IPackageImport )
+                if (o2 instanceof IPackageImport)
                 {
-                    return compareImports( ( IPackageImport ) o1, ( IPackageImport ) o2 );
+                    return compareImports((IPackageImport) o1, (IPackageImport) o2);
                 }
                 else
                 {
@@ -87,7 +84,7 @@
             }
             else
             {
-                if ( o2 instanceof IPackageImport )
+                if (o2 instanceof IPackageImport)
                 {
                     return 1;
                 }
@@ -98,81 +95,71 @@
             }
         }
 
-
-        private int compareImports( IPackageImport o1, IPackageImport o2 )
+        private int compareImports(IPackageImport o1, IPackageImport o2)
         {
-            return o1.getPackageName().compareTo( o2.getPackageName() );
+            return o1.getPackageName().compareTo(o2.getPackageName());
         }
 
-
-        private int compareBundles( IRequiredBundle o1, IRequiredBundle o2 )
+        private int compareBundles(IRequiredBundle o1, IRequiredBundle o2)
         {
-            return o1.getSymbolicName().compareTo( o2.getSymbolicName() );
+            return o1.getSymbolicName().compareTo(o2.getSymbolicName());
         }
 
     };
 
-
-    public Link( ISigilBundle source, ISigilBundle target )
+    public Link(ISigilBundle source, ISigilBundle target)
     {
         this.source = source;
         this.target = target;
     }
 
-
     public ISigilBundle getSource()
     {
         return source;
     }
 
-
     public ISigilBundle getTarget()
     {
         return target;
     }
 
-
     public boolean isSatisfied()
     {
         return target != null;
     }
 
-
-    public void addRequirement( IModelElement requirement )
+    public void addRequirement(IModelElement requirement)
     {
-        requirements.add( requirement );
-        Collections.sort( requirements, comparator );
+        requirements.add(requirement);
+        Collections.sort(requirements, comparator);
     }
 
-
     public String toString()
     {
         return "Link[" + source + "->" + target + "]";
     }
 
-
     public List<IModelElement> getRequirements()
     {
         return requirements;
     }
 
-
     public boolean isOptional()
     {
-        for ( IModelElement e : requirements )
+        for (IModelElement e : requirements)
         {
-            if ( e instanceof IPackageImport )
+            if (e instanceof IPackageImport)
             {
-                IPackageImport pi = ( IPackageImport ) e;
-                if ( !pi.isOptional() )
+                IPackageImport pi = (IPackageImport) e;
+                if (!pi.isOptional())
                 {
                     return false;
                 }
             }
-            else if ( e instanceof IRequiredBundle )
+            else if (e instanceof IRequiredBundle)
             {
-                IRequiredBundle rb = ( IRequiredBundle ) e;
-                if ( !rb.isOptional() )
+                IRequiredBundle rb = (IRequiredBundle) e;
+                if (!rb.isOptional())
                 {
                     return false;
                 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/SigilNewResourceWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/SigilNewResourceWizard.java
index 16a5353..128a803 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/SigilNewResourceWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/SigilNewResourceWizard.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.wizard;
 
-
 import org.eclipse.core.resources.IFile;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.widgets.Display;
@@ -30,7 +29,6 @@
 import org.eclipse.ui.ide.IDE;
 import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
 
-
 /**
  * @author dave
  *
@@ -38,27 +36,27 @@
 public abstract class SigilNewResourceWizard extends BasicNewResourceWizard implements INewWizard
 {
 
-    protected void selectRevealAndShow( IFile file )
+    protected void selectRevealAndShow(IFile file)
     {
-        selectAndReveal( file );
+        selectAndReveal(file);
 
         // Open editor on new file.
         IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
         try
         {
-            if ( dw != null )
+            if (dw != null)
             {
                 IWorkbenchPage page = dw.getActivePage();
-                if ( page != null )
+                if (page != null)
                 {
-                    IDE.openEditor( page, file, true );
+                    IDE.openEditor(page, file, true);
                 }
             }
         }
-        catch ( PartInitException e )
+        catch (PartInitException e)
         {
-            MessageDialog.openError( Display.getCurrent().getActiveShell(), "Initialisation error", "Failed to open "
-                + file );
+            MessageDialog.openError(Display.getCurrent().getActiveShell(),
+                "Initialisation error", "Failed to open " + file);
         }
     }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/WorkspaceContentProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/WorkspaceContentProvider.java
index 6ae5dc4..d60c7a8 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/WorkspaceContentProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/WorkspaceContentProvider.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.internal.wizard;
 
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -32,78 +31,75 @@
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 
-
 public class WorkspaceContentProvider implements ITreeContentProvider
 {
 
     private final boolean includeNonSigil;
     private final boolean includeClosed;
 
-
-    public WorkspaceContentProvider( boolean includeNonSigil, boolean includeClosed )
+    public WorkspaceContentProvider(boolean includeNonSigil, boolean includeClosed)
     {
         this.includeNonSigil = includeNonSigil;
         this.includeClosed = includeClosed;
     }
 
-
-    public Object[] getChildren( Object parentElement )
+    public Object[] getChildren(Object parentElement)
     {
         Object[] result = null;
 
-        if ( parentElement instanceof IWorkspace )
+        if (parentElement instanceof IWorkspace)
         {
-            IProject[] projects = ( ( IWorkspace ) parentElement ).getRoot().getProjects();
-            if ( includeNonSigil && includeClosed )
+            IProject[] projects = ((IWorkspace) parentElement).getRoot().getProjects();
+            if (includeNonSigil && includeClosed)
             {
                 result = projects;
             }
             else
             {
-                List<IProject> includedProjects = new ArrayList<IProject>( projects.length );
-                for ( IProject project : projects )
+                List<IProject> includedProjects = new ArrayList<IProject>(projects.length);
+                for (IProject project : projects)
                 {
-                    if ( !includeClosed && !project.isOpen() )
+                    if (!includeClosed && !project.isOpen())
                     {
                         continue;
                     }
 
-                    if ( !includeNonSigil )
+                    if (!includeNonSigil)
                     {
                         try
                         {
-                            if ( project.getNature( SigilCore.NATURE_ID ) == null )
+                            if (project.getNature(SigilCore.NATURE_ID) == null)
                             {
                                 continue;
                             }
                         }
-                        catch ( CoreException e )
+                        catch (CoreException e)
                         {
                             continue;
                         }
                     }
 
-                    includedProjects.add( project );
+                    includedProjects.add(project);
                 }
-                result = includedProjects.toArray( new IProject[includedProjects.size()] );
+                result = includedProjects.toArray(new IProject[includedProjects.size()]);
             }
         }
-        else if ( parentElement instanceof IContainer )
+        else if (parentElement instanceof IContainer)
         {
             try
             {
-                IResource[] members = ( ( IContainer ) parentElement ).members();
-                List<IResource> children = new ArrayList<IResource>( members.length );
-                for ( int i = 0; i < members.length; i++ )
+                IResource[] members = ((IContainer) parentElement).members();
+                List<IResource> children = new ArrayList<IResource>(members.length);
+                for (int i = 0; i < members.length; i++)
                 {
-                    if ( members[i].getType() != IResource.FILE )
+                    if (members[i].getType() != IResource.FILE)
                     {
-                        children.add( members[i] );
+                        children.add(members[i]);
                     }
                 }
-                result = children.toArray( new IResource[children.size()] );
+                result = children.toArray(new IResource[children.size()]);
             }
-            catch ( CoreException e )
+            catch (CoreException e)
             {
                 // Shouldn't happen
             }
@@ -112,35 +108,30 @@
         return result;
     }
 
-
-    public Object getParent( Object element )
+    public Object getParent(Object element)
     {
-        if ( element instanceof IResource )
+        if (element instanceof IResource)
         {
-            return ( ( IResource ) element ).getParent();
+            return ((IResource) element).getParent();
         }
         return null;
     }
 
-
-    public boolean hasChildren( Object element )
+    public boolean hasChildren(Object element)
     {
-        return ( element instanceof IContainer ) && ( ( IContainer ) element ).isAccessible();
+        return (element instanceof IContainer) && ((IContainer) element).isAccessible();
     }
 
-
-    public Object[] getElements( Object inputElement )
+    public Object[] getElements(Object inputElement)
     {
-        return getChildren( inputElement );
+        return getChildren(inputElement);
     }
 
-
     public void dispose()
     {
     }
 
-
-    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
     {
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/AccumulatorAdapter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/AccumulatorAdapter.java
index b017ec3..e44a064 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/AccumulatorAdapter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/AccumulatorAdapter.java
@@ -19,22 +19,19 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.Collection;
 import java.util.LinkedList;
 
-
 public abstract class AccumulatorAdapter<E> implements IAccumulator<E>
 {
-    public void addElement( E element )
+    public void addElement(E element)
     {
         LinkedList<E> list = new LinkedList<E>();
-        list.add( element );
-        addElements( list );
+        list.add(element);
+        addElements(list);
     };
 
-
-    public void addElements( Collection<? extends E> elements )
+    public void addElements(Collection<? extends E> elements)
     {
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/BackgroundLoadingSelectionDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/BackgroundLoadingSelectionDialog.java
index e70c93e..52e90f9 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/BackgroundLoadingSelectionDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/BackgroundLoadingSelectionDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -71,24 +70,23 @@
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.progress.IJobRunnable;
 
-
 public class BackgroundLoadingSelectionDialog<E> extends TitleAreaDialog implements IAccumulator<E>
 {
 
     private final ILabelProvider DEFAULT_LABEL_PROVIDER = new LabelProvider()
     {
         @SuppressWarnings("unchecked")
-        public String getText( Object element )
+        public String getText(Object element)
         {
             String result;
-            if ( element instanceof WrappedContentProposal<?> )
+            if (element instanceof WrappedContentProposal<?>)
             {
-                WrappedContentProposal<E> contentProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E> ) element;
+                WrappedContentProposal<E> contentProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E>) element;
                 result = contentProposal.getLabel();
             }
             else
             {
-                result = descriptor.getLabel( ( E ) element );
+                result = descriptor.getLabel((E) element);
             }
             return result;
         }
@@ -96,13 +94,12 @@
 
     private final IElementDescriptor<E> DEFAULT_DESCRIPTOR = new IElementDescriptor<E>()
     {
-        public String getLabel( E element )
+        public String getLabel(E element)
         {
-            return getName( element );
+            return getName(element);
         }
 
-
-        public String getName( E element )
+        public String getName(E element)
         {
             return element == null ? "null" : element.toString();
         }
@@ -124,25 +121,22 @@
 
     private HashMap<String, IJobRunnable> background = new HashMap<String, IJobRunnable>();
 
-
-    public BackgroundLoadingSelectionDialog( Shell parentShell, String selectionLabel, boolean multi )
+    public BackgroundLoadingSelectionDialog(Shell parentShell, String selectionLabel, boolean multi)
     {
-        super( parentShell );
+        super(parentShell);
         elements = new ArrayList<E>();
         this.selectionLabel = selectionLabel;
         this.multi = multi;
     }
 
-
-    public void setFilter( IFilter<? super E> filter )
+    public void setFilter(IFilter<? super E> filter)
     {
         this.filter = filter;
     }
 
-
-    public void setDescriptor( final IElementDescriptor<? super E> descriptor )
+    public void setDescriptor(final IElementDescriptor<? super E> descriptor)
     {
-        if ( descriptor != null )
+        if (descriptor != null)
         {
             this.descriptor = descriptor;
         }
@@ -152,22 +146,19 @@
         }
     }
 
-
     public IElementDescriptor<? super E> getDescriptor()
     {
         return descriptor;
     }
 
-
-    public void setComparator( Comparator<? super E> comparator )
+    public void setComparator(Comparator<? super E> comparator)
     {
         this.comparator = comparator;
     }
 
-
-    public void setLabelProvider( ILabelProvider labelProvider )
+    public void setLabelProvider(ILabelProvider labelProvider)
     {
-        if ( labelProvider != null )
+        if (labelProvider != null)
         {
             this.labelProvider = labelProvider;
         }
@@ -177,13 +168,11 @@
         }
     }
 
-
-    public void addBackgroundJob( String name, IJobRunnable job )
+    public void addBackgroundJob(String name, IJobRunnable job)
     {
-        background.put( name, job );
+        background.put(name, job);
     }
 
-
     @Override
     public int open()
     {
@@ -194,216 +183,211 @@
         }
         finally
         {
-            for ( Job j : jobs )
+            for (Job j : jobs)
             {
                 j.cancel();
             }
         }
     }
 
-
     private Job[] scheduleJobs()
     {
-        if ( background.isEmpty() )
+        if (background.isEmpty())
         {
-            return new Job[]
-                {};
+            return new Job[] {};
         }
         else
         {
-            ArrayList<Job> jobs = new ArrayList<Job>( background.size() );
-            for ( Map.Entry<String, IJobRunnable> e : background.entrySet() )
+            ArrayList<Job> jobs = new ArrayList<Job>(background.size());
+            for (Map.Entry<String, IJobRunnable> e : background.entrySet())
             {
                 final IJobRunnable run = e.getValue();
-                Job job = new Job( e.getKey() )
+                Job job = new Job(e.getKey())
                 {
                     @Override
-                    protected IStatus run( IProgressMonitor monitor )
+                    protected IStatus run(IProgressMonitor monitor)
                     {
-                        return run.run( monitor );
+                        return run.run(monitor);
                     }
                 };
                 job.schedule();
             }
 
-            return jobs.toArray( new Job[jobs.size()] );
+            return jobs.toArray(new Job[jobs.size()]);
         }
     }
 
-
     @Override
-    protected Control createDialogArea( Composite parent )
+    protected Control createDialogArea(Composite parent)
     {
         // Create Controls
-        Composite container = ( Composite ) super.createDialogArea( parent );
-        Composite composite = new Composite( container, SWT.NONE );
+        Composite container = (Composite) super.createDialogArea(parent);
+        Composite composite = new Composite(container, SWT.NONE);
 
-        new Label( composite, SWT.NONE ).setText( selectionLabel );
+        new Label(composite, SWT.NONE).setText(selectionLabel);
 
         ContentProposalAdapter proposalAdapter = null;
         Text txtSelection = null;
 
         Table table = null;
-        if ( multi )
+        if (multi)
         {
-            table = new Table( composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER );
-            viewer = new TableViewer( table );
-            viewer.setContentProvider( new ArrayContentProvider() );
-            viewer.addFilter( new ViewerFilter()
+            table = new Table(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
+            viewer = new TableViewer(table);
+            viewer.setContentProvider(new ArrayContentProvider());
+            viewer.addFilter(new ViewerFilter()
             {
-                public boolean select( Viewer viewer, Object parentElement, Object element )
+                public boolean select(Viewer viewer, Object parentElement, Object element)
                 {
                     @SuppressWarnings("unchecked")
-                    E castedElement = ( E ) element;
-                    return filter == null || filter.select( castedElement );
+                    E castedElement = (E) element;
+                    return filter == null || filter.select(castedElement);
                 }
-            } );
-            if ( comparator != null )
+            });
+            if (comparator != null)
             {
-                viewer.setSorter( new ViewerSorter()
+                viewer.setSorter(new ViewerSorter()
                 {
                     @Override
-                    public int compare( Viewer viewer, Object o1, Object o2 )
+                    public int compare(Viewer viewer, Object o1, Object o2)
                     {
                         @SuppressWarnings("unchecked")
-                        E e1 = ( E ) o1;
+                        E e1 = (E) o1;
                         @SuppressWarnings("unchecked")
-                        E e2 = ( E ) o2;
-                        return comparator.compare( e1, e2 );
+                        E e2 = (E) o2;
+                        return comparator.compare(e1, e2);
                     }
-                } );
+                });
             }
-            synchronized ( elements )
+            synchronized (elements)
             {
-                viewer.setInput( elements );
+                viewer.setInput(elements);
             }
 
-            if ( labelProvider != null )
+            if (labelProvider != null)
             {
-                viewer.setLabelProvider( labelProvider );
+                viewer.setLabelProvider(labelProvider);
             }
         }
         else
         {
-            txtSelection = new Text( composite, SWT.BORDER );
-            ControlDecoration selectionDecor = new ControlDecoration( txtSelection, SWT.LEFT | SWT.TOP );
+            txtSelection = new Text(composite, SWT.BORDER);
+            ControlDecoration selectionDecor = new ControlDecoration(txtSelection,
+                SWT.LEFT | SWT.TOP);
             FieldDecoration proposalDecor = FieldDecorationRegistry.getDefault().getFieldDecoration(
-                FieldDecorationRegistry.DEC_CONTENT_PROPOSAL );
-            selectionDecor.setImage( proposalDecor.getImage() );
-            selectionDecor.setDescriptionText( proposalDecor.getDescription() );
+                FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+            selectionDecor.setImage(proposalDecor.getImage());
+            selectionDecor.setDescriptionText(proposalDecor.getDescription());
 
-            ExclusionContentProposalProvider<E> proposalProvider = new ExclusionContentProposalProvider<E>( elements,
-                filter, descriptor );
+            ExclusionContentProposalProvider<E> proposalProvider = new ExclusionContentProposalProvider<E>(
+                elements, filter, descriptor);
 
-            proposalAdapter = new ContentProposalAdapter( txtSelection, new TextContentAdapter(), proposalProvider,
-                null, null );
-            proposalAdapter.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE );
-            if ( labelProvider != null )
+            proposalAdapter = new ContentProposalAdapter(txtSelection,
+                new TextContentAdapter(), proposalProvider, null, null);
+            proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
+            if (labelProvider != null)
             {
-                proposalAdapter.setLabelProvider( labelProvider );
+                proposalAdapter.setLabelProvider(labelProvider);
             }
 
-            if ( selectedName != null )
+            if (selectedName != null)
             {
-                txtSelection.setText( selectedName );
+                txtSelection.setText(selectedName);
             }
         }
         updateSelection();
         updateButtons();
 
         // Hookup listeners
-        if ( proposalAdapter != null )
+        if (proposalAdapter != null)
         {
-            proposalAdapter.addContentProposalListener( new IContentProposalListener()
+            proposalAdapter.addContentProposalListener(new IContentProposalListener()
             {
-                public void proposalAccepted( IContentProposal proposal )
+                public void proposalAccepted(IContentProposal proposal)
                 {
                     @SuppressWarnings("unchecked")
-                    WrappedContentProposal<E> valueProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E> ) proposal;
+                    WrappedContentProposal<E> valueProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E>) proposal;
                     E selected = valueProposal.getElement();
-                    selection = new ArrayList<E>( 1 );
-                    selection.add( selected );
+                    selection = new ArrayList<E>(1);
+                    selection.add(selected);
 
-                    elementSelected( selected );
+                    elementSelected(selected);
 
                     updateButtons();
                 }
-            } );
+            });
         }
-        if ( txtSelection != null )
+        if (txtSelection != null)
         {
-            txtSelection.addModifyListener( new ModifyListener()
+            txtSelection.addModifyListener(new ModifyListener()
             {
-                public void modifyText( ModifyEvent e )
+                public void modifyText(ModifyEvent e)
                 {
-                    selectedName = ( ( Text ) e.widget ).getText();
+                    selectedName = ((Text) e.widget).getText();
                     updateButtons();
                 }
-            } );
+            });
         }
-        if ( viewer != null )
+        if (viewer != null)
         {
-            viewer.addSelectionChangedListener( new ISelectionChangedListener()
+            viewer.addSelectionChangedListener(new ISelectionChangedListener()
             {
-                public void selectionChanged( SelectionChangedEvent event )
+                public void selectionChanged(SelectionChangedEvent event)
                 {
-                    IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
-                    selection = new ArrayList<E>( sel.size() );
-                    for ( Iterator<?> iter = sel.iterator(); iter.hasNext(); )
+                    IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+                    selection = new ArrayList<E>(sel.size());
+                    for (Iterator<?> iter = sel.iterator(); iter.hasNext();)
                     {
                         @SuppressWarnings("unchecked")
-                        E element = ( E ) iter.next();
-                        selection.add( element );
+                        E element = (E) iter.next();
+                        selection.add(element);
                     }
                     updateButtons();
                 }
-            } );
-            viewer.addOpenListener( new IOpenListener()
+            });
+            viewer.addOpenListener(new IOpenListener()
             {
-                public void open( OpenEvent event )
+                public void open(OpenEvent event)
                 {
-                    if ( canComplete() )
+                    if (canComplete())
                     {
-                        setReturnCode( IDialogConstants.OK_ID );
+                        setReturnCode(IDialogConstants.OK_ID);
                         close();
                     }
                 }
-            } );
+            });
         }
 
         // Layout
-        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        if ( multi )
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        if (multi)
         {
-            composite.setLayout( new GridLayout( 1, false ) );
-            GridData layoutTable = new GridData( SWT.FILL, SWT.FILL, true, true );
+            composite.setLayout(new GridLayout(1, false));
+            GridData layoutTable = new GridData(SWT.FILL, SWT.FILL, true, true);
             layoutTable.heightHint = 200;
-            table.setLayoutData( layoutTable );
+            table.setLayoutData(layoutTable);
         }
         else
         {
-            composite.setLayout( new GridLayout( 2, false ) );
-            txtSelection.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+            composite.setLayout(new GridLayout(2, false));
+            txtSelection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
         }
 
         return container;
     }
 
-
-    protected void elementSelected( E selection )
+    protected void elementSelected(E selection)
     {
     }
 
-
     @Override
-    protected Control createButtonBar( Composite parent )
+    protected Control createButtonBar(Composite parent)
     {
-        Control bar = super.createButtonBar( parent );
+        Control bar = super.createButtonBar(parent);
         updateButtons();
         return bar;
     }
 
-
     /**
      * Can be called from any thread
      */
@@ -414,24 +398,23 @@
             public void run()
             {
                 Shell shell = getShell();
-                if ( shell != null && !shell.isDisposed() )
+                if (shell != null && !shell.isDisposed())
                 {
-                    Button okButton = getButton( IDialogConstants.OK_ID );
-                    if ( okButton != null && !okButton.isDisposed() )
+                    Button okButton = getButton(IDialogConstants.OK_ID);
+                    if (okButton != null && !okButton.isDisposed())
                     {
-                        okButton.setEnabled( canComplete() );
+                        okButton.setEnabled(canComplete());
                     }
                 }
             }
         };
         Shell shell = getShell();
-        if ( shell != null )
+        if (shell != null)
         {
-            onUIThread( shell, updateButtonsRunnable );
+            onUIThread(shell, updateButtonsRunnable);
         }
     }
 
-
     /**
      * Subclasses may override but must call super.canComplete
      * @return
@@ -440,60 +423,58 @@
     {
         boolean result = false;
 
-        if ( selection != null )
+        if (selection != null)
         {
-            if ( multi )
+            if (multi)
             {
                 result = selection.size() > 0;
             }
             else
             {
                 E sel = getSelectedElement();
-                result = sel != null && descriptor.getName( sel ).equals( selectedName );
+                result = sel != null && descriptor.getName(sel).equals(selectedName);
             }
         }
 
         return result;
     }
 
-
-    public final void addElement( E added )
+    public final void addElement(E added)
     {
-        addElements( Collections.singleton( added ) );
+        addElements(Collections.singleton(added));
     }
 
-
     /**
      * Can be called from any thread
      */
-    public final void addElements( Collection<? extends E> added )
+    public final void addElements(Collection<? extends E> added)
     {
         final LinkedList<E> toAdd = new LinkedList<E>();
-        synchronized ( elements )
+        synchronized (elements)
         {
-            for ( E e : added )
+            for (E e : added)
             {
-                if ( !elements.contains( e ) )
+                if (!elements.contains(e))
                 {
-                    elements.add( e );
-                    toAdd.add( e );
+                    elements.add(e);
+                    toAdd.add(e);
                 }
             }
-            Collections.sort( elements, comparator );
+            Collections.sort(elements, comparator);
         }
-        if ( viewer != null )
+        if (viewer != null)
         {
-            onUIThread( viewer.getControl(), new Runnable()
+            onUIThread(viewer.getControl(), new Runnable()
             {
                 public void run()
                 {
-                    if ( !viewer.getControl().isDisposed() )
+                    if (!viewer.getControl().isDisposed())
                     {
-                        viewer.add( toAdd.toArray() );
+                        viewer.add(toAdd.toArray());
                         viewer.refresh();
                     }
                 }
-            } );
+            });
         }
         else
         {
@@ -503,23 +484,22 @@
         updateButtons();
     }
 
-
     protected void updateSelection()
     {
-        onUIThread( getShell(), new Runnable()
+        onUIThread(getShell(), new Runnable()
         {
             public void run()
             {
-                if ( selectedName != null )
+                if (selectedName != null)
                 {
                     ArrayList<E> newSelection = new ArrayList<E>();
-                    synchronized ( elements )
+                    synchronized (elements)
                     {
-                        for ( E e : elements )
+                        for (E e : elements)
                         {
-                            if ( selectedName.equals( descriptor.getName( e ) ) )
+                            if (selectedName.equals(descriptor.getName(e)))
                             {
-                                newSelection.add( e );
+                                newSelection.add(e);
                                 break;
                             }
                         }
@@ -530,24 +510,23 @@
                 {
                     selection = Collections.emptyList();
                 }
-                if ( viewer != null && !viewer.getControl().isDisposed() )
+                if (viewer != null && !viewer.getControl().isDisposed())
                 {
-                    viewer.setSelection( selection.isEmpty() ? StructuredSelection.EMPTY : new StructuredSelection(
-                        selection ) );
+                    viewer.setSelection(selection.isEmpty() ? StructuredSelection.EMPTY
+                        : new StructuredSelection(selection));
                 }
             }
-        } );
+        });
     }
 
-
-    private static final void onUIThread( Control control, Runnable r )
+    private static final void onUIThread(Control control, Runnable r)
     {
-        if ( control != null && !control.isDisposed() )
+        if (control != null && !control.isDisposed())
         {
             try
             {
                 Display display = control.getDisplay();
-                if ( Thread.currentThread() == display.getThread() )
+                if (Thread.currentThread() == display.getThread())
                 {
                     // We are on the UI thread already, just do the work
                     r.run();
@@ -555,12 +534,12 @@
                 else
                 {
                     // Not on the UI thread, need to bung over the runnable
-                    display.asyncExec( r );
+                    display.asyncExec(r);
                 }
             }
-            catch ( SWTError e )
+            catch (SWTError e)
             {
-                if ( e.code == SWT.ERROR_WIDGET_DISPOSED )
+                if (e.code == SWT.ERROR_WIDGET_DISPOSED)
                 {
                     // ignore
                 }
@@ -572,60 +551,57 @@
         }
     }
 
-
     public String getSelectedName()
     {
         return selectedName;
     }
 
-
-    public void setSelectedName( String selectedName )
+    public void setSelectedName(String selectedName)
     {
         this.selectedName = selectedName;
         boolean change = false;
-        if ( selectedName == null )
+        if (selectedName == null)
         {
-            if ( selection != null && !selection.isEmpty() )
+            if (selection != null && !selection.isEmpty())
             {
                 change = true;
             }
         }
         else
         {
-            if ( selection == null )
+            if (selection == null)
             {
                 change = true;
             }
-            else if ( selection.size() != 1 || !descriptor.getLabel( selection.get( 0 ) ).equals( selectedName ) )
+            else if (selection.size() != 1
+                || !descriptor.getLabel(selection.get(0)).equals(selectedName))
             {
                 change = true;
             }
         }
 
-        if ( change )
+        if (change)
         {
             updateSelection();
             updateButtons();
         }
     }
 
-
     public List<E> getSelectedElements()
     {
         return selection;
     }
 
-
     public E getSelectedElement()
     {
         E result;
-        if ( selection == null || selection.isEmpty() )
+        if (selection == null || selection.isEmpty())
         {
             result = null;
         }
         else
         {
-            result = selection.get( 0 );
+            result = selection.get(0);
         }
         return result;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ColumnModelLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ColumnModelLabelProvider.java
index ecf680d..375e572 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ColumnModelLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ColumnModelLabelProvider.java
@@ -19,28 +19,24 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.swt.graphics.Image;
 
-
 public class ColumnModelLabelProvider extends ColumnLabelProvider
 {
 
     private ModelLabelProvider provider = new ModelLabelProvider();
 
-
     @Override
-    public Image getImage( Object element )
+    public Image getImage(Object element)
     {
-        return provider.getImage( element );
+        return provider.getImage(element);
     }
 
-
     @Override
-    public String getText( Object element )
+    public String getText(Object element)
     {
-        return provider.getText( element );
+        return provider.getText(element);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultContentProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultContentProvider.java
index f17eaec..88c46e3 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultContentProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultContentProvider.java
@@ -19,11 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import org.eclipse.jface.viewers.IContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 
-
 public class DefaultContentProvider implements IContentProvider
 {
 
@@ -31,8 +29,7 @@
     {
     }
 
-
-    public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
     {
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultLabelProvider.java
index 18a1e17..c6800c5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultLabelProvider.java
@@ -19,32 +19,27 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import org.eclipse.jface.viewers.IBaseLabelProvider;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.ILabelProviderListener;
 
-
 public abstract class DefaultLabelProvider implements IBaseLabelProvider, ILabelProvider
 {
 
-    public boolean isLabelProperty( Object element, String property )
+    public boolean isLabelProperty(Object element, String property)
     {
         return false;
     }
 
-
     public void dispose()
     {
     }
 
-
-    public void addListener( ILabelProviderListener listener )
+    public void addListener(ILabelProviderListener listener)
     {
     }
 
-
-    public void removeListener( ILabelProviderListener listener )
+    public void removeListener(ILabelProviderListener listener)
     {
     }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTableProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTableProvider.java
index defe741..48234c6 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTableProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTableProvider.java
@@ -19,12 +19,10 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.Collection;
 
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 
-
 public abstract class DefaultTableProvider extends DefaultContentProvider implements IStructuredContentProvider
 {
 
@@ -39,25 +37,25 @@
      *  
      * @throws IllegalArgumentException if the element cannot be converted. 
      */
-    public Object[] toArray( Object inputElement )
+    public Object[] toArray(Object inputElement)
     {
-        if ( inputElement == null )
+        if (inputElement == null)
         {
-            return new Object[]
-                {};
+            return new Object[] {};
         }
-        else if ( inputElement instanceof Collection )
+        else if (inputElement instanceof Collection)
         {
-            Collection<?> col = ( Collection<?> ) inputElement;
+            Collection<?> col = (Collection<?>) inputElement;
             return col.toArray();
         }
-        else if ( inputElement.getClass().isArray() )
+        else if (inputElement.getClass().isArray())
         {
-            return ( Object[] ) inputElement;
+            return (Object[]) inputElement;
         }
         else
         {
-            throw new IllegalArgumentException( "Invalid inputElement " + inputElement.getClass() );
+            throw new IllegalArgumentException("Invalid inputElement "
+                + inputElement.getClass());
         }
     }
 
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTreeContentProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTreeContentProvider.java
index f7487db..5b6580e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTreeContentProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTreeContentProvider.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import org.eclipse.jface.viewers.ITreeContentProvider;
 
-
 public abstract class DefaultTreeContentProvider extends DefaultContentProvider implements ITreeContentProvider
 {
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExclusionContentProposalProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExclusionContentProposalProvider.java
index 96a3e10..5348801 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExclusionContentProposalProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExclusionContentProposalProvider.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -31,7 +30,6 @@
 import org.eclipse.jface.fieldassist.IContentProposal;
 import org.eclipse.jface.fieldassist.IContentProposalProvider;
 
-
 public class ExclusionContentProposalProvider<T> implements IContentProposalProvider
 {
 
@@ -39,46 +37,44 @@
     private final IFilter<? super T> filter;
     private final IElementDescriptor<? super T> descriptor;
 
-
-    public ExclusionContentProposalProvider( Collection<? extends T> elements, IFilter<? super T> filter,
-        IElementDescriptor<? super T> descriptor )
+    public ExclusionContentProposalProvider(Collection<? extends T> elements, IFilter<? super T> filter, IElementDescriptor<? super T> descriptor)
     {
         this.elements = elements;
         this.filter = filter;
         this.descriptor = descriptor;
     }
 
-
-    public IContentProposal[] getProposals( String contents, int position )
+    public IContentProposal[] getProposals(String contents, int position)
     {
-        String matchString = contents.substring( 0, position );
-        Pattern pattern = GlobCompiler.compile( matchString );
+        String matchString = contents.substring(0, position);
+        Pattern pattern = GlobCompiler.compile(matchString);
 
         // Get a snapshot of the elements
         T[] elementArray;
-        synchronized ( elements )
+        synchronized (elements)
         {
             @SuppressWarnings("unchecked")
-            T[] temp = ( T[] ) elements.toArray();
+            T[] temp = (T[]) elements.toArray();
             elementArray = temp;
         }
 
         List<IContentProposal> result = new ArrayList<IContentProposal>();
 
-        for ( T element : elementArray )
+        for (T element : elementArray)
         {
-            if ( filter == null || filter.select( element ) )
+            if (filter == null || filter.select(element))
             {
-                IContentProposal proposal = WrappedContentProposal.newInstance( element, descriptor );
-                Matcher matcher = pattern.matcher( proposal.getContent() );
-                if ( matcher.find() )
+                IContentProposal proposal = WrappedContentProposal.newInstance(element,
+                    descriptor);
+                Matcher matcher = pattern.matcher(proposal.getContent());
+                if (matcher.find())
                 {
-                    result.add( proposal );
+                    result.add(proposal);
                 }
             }
         }
 
-        return result.toArray( new IContentProposal[result.size()] );
+        return result.toArray(new IContentProposal[result.size()]);
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExportedPackageFinder.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExportedPackageFinder.java
index e48d682..65eab4f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExportedPackageFinder.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExportedPackageFinder.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -33,46 +32,44 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.ui.progress.IJobRunnable;
 
-
 public class ExportedPackageFinder implements IJobRunnable
 {
 
     private final IAccumulator<? super IPackageExport> accumulator;
     private final ISigilProjectModel sigil;
 
-
-    public ExportedPackageFinder( ISigilProjectModel sigil, IAccumulator<? super IPackageExport> accumulator )
+    public ExportedPackageFinder(ISigilProjectModel sigil, IAccumulator<? super IPackageExport> accumulator)
     {
         this.sigil = sigil;
         this.accumulator = accumulator;
     }
 
-
-    public IStatus run( final IProgressMonitor monitor )
+    public IStatus run(final IProgressMonitor monitor)
     {
-        final List<IPackageExport> exports = new ArrayList<IPackageExport>( ResourcesDialogHelper.UPDATE_BATCH_SIZE );
+        final List<IPackageExport> exports = new ArrayList<IPackageExport>(
+            ResourcesDialogHelper.UPDATE_BATCH_SIZE);
         final IModelWalker walker = new IModelWalker()
         {
-            public boolean visit( IModelElement element )
+            public boolean visit(IModelElement element)
             {
-                if ( element instanceof IPackageExport )
+                if (element instanceof IPackageExport)
                 {
-                    IPackageExport pkgExport = ( IPackageExport ) element;
-                    exports.add( pkgExport );
+                    IPackageExport pkgExport = (IPackageExport) element;
+                    exports.add(pkgExport);
 
-                    if ( exports.size() >= ResourcesDialogHelper.UPDATE_BATCH_SIZE )
+                    if (exports.size() >= ResourcesDialogHelper.UPDATE_BATCH_SIZE)
                     {
-                        accumulator.addElements( exports );
+                        accumulator.addElements(exports);
                         exports.clear();
                     }
                 }
                 return !monitor.isCanceled();
             }
         };
-        SigilCore.getRepositoryManager( sigil ).visit( walker );
-        if ( exports.size() > 0 )
+        SigilCore.getRepositoryManager(sigil).visit(walker);
+        if (exports.size() > 0)
         {
-            accumulator.addElements( exports );
+            accumulator.addElements(exports);
         }
 
         return Status.OK_STATUS;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/FileUtils.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/FileUtils.java
index 5e15831..51160e0 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/FileUtils.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/FileUtils.java
@@ -19,36 +19,34 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.DirectoryDialog;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 
-
 public class FileUtils
 {
-    public static void loadFile( Shell shell, Text text, String msg, boolean isDirectory )
+    public static void loadFile(Shell shell, Text text, String msg, boolean isDirectory)
     {
-        if ( isDirectory )
+        if (isDirectory)
         {
-            DirectoryDialog dialog = new DirectoryDialog( shell, SWT.NONE );
-            dialog.setMessage( msg );
+            DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE);
+            dialog.setMessage(msg);
             String value = dialog.open();
-            if ( value != null )
+            if (value != null)
             {
-                text.setText( value );
+                text.setText(value);
             }
         }
         else
         {
-            FileDialog dialog = new FileDialog( shell, SWT.NONE );
-            dialog.setText( msg );
+            FileDialog dialog = new FileDialog(shell, SWT.NONE);
+            dialog.setText(msg);
             String value = dialog.open();
-            if ( value != null )
+            if (value != null)
             {
-                text.setText( value );
+                text.setText(value);
             }
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IAccumulator.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IAccumulator.java
index 5ee046e..daa5f15 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IAccumulator.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IAccumulator.java
@@ -19,14 +19,11 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.Collection;
 
-
 public interface IAccumulator<E>
 {
-    public void addElement( E element );
+    public void addElement(E element);
 
-
-    public void addElements( Collection<? extends E> elements );
+    public void addElements(Collection<? extends E> elements);
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IElementDescriptor.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IElementDescriptor.java
index 463f888..57aadc9 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IElementDescriptor.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IElementDescriptor.java
@@ -19,14 +19,12 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 public interface IElementDescriptor<E>
 {
     /**
      * Return the short identifying name of the element.
      */
-    String getName( E element );
-
+    String getName(E element);
 
     /**
      * Return a label for the element, including the name but possibly supplying
@@ -35,5 +33,5 @@
      * @param element
      * @return
      */
-    String getLabel( E element );
+    String getLabel(E element);
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IExportToImportConverter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IExportToImportConverter.java
index 8f51f10..1ddc6fe 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IExportToImportConverter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IExportToImportConverter.java
@@ -19,8 +19,7 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 public interface IExportToImportConverter<E, I>
 {
-    I convert( E exportElement );
+    I convert(E exportElement);
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IFilter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IFilter.java
index f8a7e79..0d33c3a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IFilter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IFilter.java
@@ -19,8 +19,7 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 public interface IFilter<T>
 {
-    boolean select( T element );
+    boolean select(T element);
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IValidationListener.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IValidationListener.java
index fb47833..e325c5e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IValidationListener.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IValidationListener.java
@@ -19,10 +19,9 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 public interface IValidationListener
 {
 
-    void validationMessage( String message, int level );
+    void validationMessage(String message, int level);
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
index e1a54c7..74fbcf5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.Set;
 
 import org.apache.felix.sigil.common.model.IModelElement;
@@ -41,40 +40,39 @@
 import org.eclipse.swt.graphics.Image;
 import org.osgi.framework.Version;
 
-
 public class ModelLabelProvider extends LabelProvider
 {
     private volatile Set<? extends IModelElement> unresolvedElements = null;
 
-
-    public Image getImage( Object element )
+    public Image getImage(Object element)
     {
-        boolean unresolved = ( unresolvedElements == null ) ? false : unresolvedElements.contains( element );
+        boolean unresolved = (unresolvedElements == null) ? false
+            : unresolvedElements.contains(element);
 
-        if ( element instanceof ISigilBundle || element instanceof IBundleModelElement )
+        if (element instanceof ISigilBundle || element instanceof IBundleModelElement)
         {
             return findBundle();
         }
-        else if ( element instanceof IRequiredBundle )
+        else if (element instanceof IRequiredBundle)
         {
-            boolean optional = ( ( IRequiredBundle ) element ).isOptional();
-            return findRequiredBundle( optional, unresolved );
+            boolean optional = ((IRequiredBundle) element).isOptional();
+            return findRequiredBundle(optional, unresolved);
         }
-        else if ( element instanceof IPackageImport )
+        else if (element instanceof IPackageImport)
         {
-            boolean optional = ( ( IPackageImport ) element ).isOptional();
-            return findPackageImport( optional, unresolved );
+            boolean optional = ((IPackageImport) element).isOptional();
+            return findPackageImport(optional, unresolved);
         }
-        else if ( element instanceof IPackageExport )
+        else if (element instanceof IPackageExport)
         {
             return findPackageExport();
         }
-        else if ( element instanceof IPackageFragmentRoot )
+        else if (element instanceof IPackageFragmentRoot)
         {
-            IPackageFragmentRoot root = ( IPackageFragmentRoot ) element;
+            IPackageFragmentRoot root = (IPackageFragmentRoot) element;
             try
             {
-                if ( root.getKind() == IPackageFragmentRoot.K_SOURCE )
+                if (root.getKind() == IPackageFragmentRoot.K_SOURCE)
                 {
                     return findPackage();
                 }
@@ -83,154 +81,154 @@
                     return findBundle();
                 }
             }
-            catch ( JavaModelException e )
+            catch (JavaModelException e)
             {
-                SigilCore.error( "Failed to inspect package fragment root", e );
+                SigilCore.error("Failed to inspect package fragment root", e);
             }
         }
-        else if ( element instanceof IClasspathEntry )
+        else if (element instanceof IClasspathEntry)
         {
             return findPackage();
         }
-        if ( element instanceof IBundleRepository )
+        if (element instanceof IBundleRepository)
         {
-            IBundleRepository rep = ( IBundleRepository ) element;
-            IRepositoryModel config = SigilCore.getRepositoryConfiguration().findRepository( rep.getId() );
+            IBundleRepository rep = (IBundleRepository) element;
+            IRepositoryModel config = SigilCore.getRepositoryConfiguration().findRepository(
+                rep.getId());
             return config.getType().getIcon();
         }
 
         return null;
     }
 
-
-    public String getText( Object element )
+    public String getText(Object element)
     {
-        if ( element instanceof ISigilBundle )
+        if (element instanceof ISigilBundle)
         {
-            ISigilBundle bundle = ( ISigilBundle ) element;
-            return bundle.getBundleInfo().getSymbolicName() + " " + bundle.getBundleInfo().getVersion();
+            ISigilBundle bundle = (ISigilBundle) element;
+            return bundle.getBundleInfo().getSymbolicName() + " "
+                + bundle.getBundleInfo().getVersion();
         }
-        if ( element instanceof IBundleModelElement )
+        if (element instanceof IBundleModelElement)
         {
-            IBundleModelElement bundle = ( IBundleModelElement ) element;
+            IBundleModelElement bundle = (IBundleModelElement) element;
             return bundle.getSymbolicName();
         }
-        if ( element instanceof IRequiredBundle )
+        if (element instanceof IRequiredBundle)
         {
-            IRequiredBundle req = ( IRequiredBundle ) element;
+            IRequiredBundle req = (IRequiredBundle) element;
             return req.getSymbolicName() + " " + req.getVersions();
         }
 
-        if ( element instanceof IPackageImport )
+        if (element instanceof IPackageImport)
         {
-            IPackageImport req = ( IPackageImport ) element;
+            IPackageImport req = (IPackageImport) element;
             return req.getPackageName() + " " + req.getVersions();
         }
 
-        if ( element instanceof IPackageExport )
+        if (element instanceof IPackageExport)
         {
-            IPackageExport pe = ( IPackageExport ) element;
+            IPackageExport pe = (IPackageExport) element;
             Version rawVersion = pe.getRawVersion();
-            return rawVersion != null ? pe.getPackageName() + " " + rawVersion : pe.getPackageName();
+            return rawVersion != null ? pe.getPackageName() + " " + rawVersion
+                : pe.getPackageName();
         }
 
-        if ( element instanceof IResource )
+        if (element instanceof IResource)
         {
-            IResource resource = ( IResource ) element;
+            IResource resource = (IResource) element;
             return resource.getName();
         }
 
-        if ( element instanceof IPackageFragment )
+        if (element instanceof IPackageFragment)
         {
-            IPackageFragment f = ( IPackageFragment ) element;
+            IPackageFragment f = (IPackageFragment) element;
             return f.getElementName();
         }
 
-        if ( element instanceof IPackageFragmentRoot )
+        if (element instanceof IPackageFragmentRoot)
         {
-            IPackageFragmentRoot f = ( IPackageFragmentRoot ) element;
+            IPackageFragmentRoot f = (IPackageFragmentRoot) element;
             try
             {
                 return f.getUnderlyingResource().getName();
             }
-            catch ( JavaModelException e )
+            catch (JavaModelException e)
             {
                 return "unknown";
             }
         }
 
-        if ( element instanceof IClasspathEntry )
+        if (element instanceof IClasspathEntry)
         {
-            IClasspathEntry cp = ( IClasspathEntry ) element;
+            IClasspathEntry cp = (IClasspathEntry) element;
             return cp.getPath().toString();
         }
 
-        if ( element instanceof IBundleRepository )
+        if (element instanceof IBundleRepository)
         {
-            IBundleRepository rep = ( IBundleRepository ) element;
-            IRepositoryModel config = SigilCore.getRepositoryConfiguration().findRepository( rep.getId() );
+            IBundleRepository rep = (IBundleRepository) element;
+            IRepositoryModel config = SigilCore.getRepositoryConfiguration().findRepository(
+                rep.getId());
             return config.getName();
         }
 
         return element.toString();
     }
 
-
     private Image findPackage()
     {
-        return cacheImage( "icons/package.gif" );
+        return cacheImage("icons/package.gif");
     }
 
-
-    private Image findPackageImport( boolean optional, boolean unresolved )
+    private Image findPackageImport(boolean optional, boolean unresolved)
     {
         String path;
-        if ( optional )
+        if (optional)
         {
-            path = unresolved ? "icons/import-package-optional-error.gif" : "icons/import-package-optional.gif";
+            path = unresolved ? "icons/import-package-optional-error.gif"
+                : "icons/import-package-optional.gif";
         }
         else
         {
-            path = unresolved ? "icons/import-package-error.gif" : "icons/import-package.gif";
+            path = unresolved ? "icons/import-package-error.gif"
+                : "icons/import-package.gif";
         }
-        return cacheImage( path );
+        return cacheImage(path);
     }
 
-
     private Image findPackageExport()
     {
-        return cacheImage( "icons/export-package.gif" );
+        return cacheImage("icons/export-package.gif");
     }
 
-
     private Image findBundle()
     {
-        return cacheImage( "icons/bundle.gif" );
+        return cacheImage("icons/bundle.gif");
     }
 
-
-    private Image findRequiredBundle( boolean optional, boolean unresolved )
+    private Image findRequiredBundle(boolean optional, boolean unresolved)
     {
         String path;
-        if ( optional )
+        if (optional)
         {
-            path = unresolved ? "icons/require-bundle-optional-error.gif" : "icons/require-bundle-optional.gif";
+            path = unresolved ? "icons/require-bundle-optional-error.gif"
+                : "icons/require-bundle-optional.gif";
         }
         else
         {
-            path = unresolved ? "icons/require-bundle-error.gif" : "icons/require-bundle.gif";
+            path = unresolved ? "icons/require-bundle-error.gif"
+                : "icons/require-bundle.gif";
         }
-        return cacheImage( path );
+        return cacheImage(path);
     }
 
-
-    private static Image cacheImage( String path )
+    private static Image cacheImage(String path)
     {
-        return SigilUI.cacheImage( path, ModelLabelProvider.class.getClassLoader() );
+        return SigilUI.cacheImage(path, ModelLabelProvider.class.getClassLoader());
     }
 
-
-    public void setUnresolvedElements( Set<? extends IModelElement> elements )
+    public void setUnresolvedElements(Set<? extends IModelElement> elements)
     {
         this.unresolvedElements = elements;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/PackageFilter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/PackageFilter.java
index e5c460b..5aa3c03 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/PackageFilter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/PackageFilter.java
@@ -19,41 +19,36 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.felix.sigil.common.model.osgi.IPackageExport;
 import org.apache.felix.sigil.common.model.osgi.IPackageImport;
 
-
 public class PackageFilter implements IFilter<IPackageImport>
 {
 
     private Set<String> names = new HashSet<String>();
 
-
-    public PackageFilter( String[] packageNames )
+    public PackageFilter(String[] packageNames)
     {
-        for ( String name : packageNames )
+        for (String name : packageNames)
         {
-            names.add( name );
+            names.add(name);
         }
     }
 
-
-    public PackageFilter( IPackageExport[] packages )
+    public PackageFilter(IPackageExport[] packages)
     {
-        for ( IPackageExport packageExport : packages )
+        for (IPackageExport packageExport : packages)
         {
-            names.add( packageExport.getPackageName() );
+            names.add(packageExport.getPackageName());
         }
     }
 
-
-    public boolean select( IPackageImport element )
+    public boolean select(IPackageImport element)
     {
-        return !names.contains( element.getPackageName() );
+        return !names.contains(element.getPackageName());
     }
 
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ProjectUtils.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ProjectUtils.java
index 79aa846..73ffa6c 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ProjectUtils.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ProjectUtils.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.concurrent.Callable;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
@@ -30,26 +29,24 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.actions.WorkspaceModifyOperation;
 
-
 public class ProjectUtils
 {
-    public static boolean runTaskWithRebuildCheck( final Runnable task, Shell shell )
+    public static boolean runTaskWithRebuildCheck(final Runnable task, Shell shell)
     {
-        return runTaskWithRebuildCheck( new Callable<Boolean>()
+        return runTaskWithRebuildCheck(new Callable<Boolean>()
         {
             public Boolean call() throws Exception
             {
                 task.run();
                 return true;
             }
-        }, shell );
+        }, shell);
     }
 
-
-    public static boolean runTaskWithRebuildCheck( Callable<Boolean> callable, Shell shell )
+    public static boolean runTaskWithRebuildCheck(Callable<Boolean> callable, Shell shell)
     {
-        int result = checkRebuild( shell );
-        if ( result == IDialogConstants.CANCEL_ID )
+        int result = checkRebuild(shell);
+        if (result == IDialogConstants.CANCEL_ID)
         {
             return false;
         }
@@ -57,18 +54,18 @@
         {
             try
             {
-                if ( Boolean.TRUE == callable.call() )
+                if (Boolean.TRUE == callable.call())
                 {
-                    if ( result == IDialogConstants.YES_ID )
+                    if (result == IDialogConstants.YES_ID)
                     {
-                        SigilUI.runWorkspaceOperation( new WorkspaceModifyOperation()
+                        SigilUI.runWorkspaceOperation(new WorkspaceModifyOperation()
                         {
                             @Override
-                            protected void execute( IProgressMonitor monitor )
+                            protected void execute(IProgressMonitor monitor)
                             {
-                                SigilCore.rebuildAllBundleDependencies( monitor );
+                                SigilCore.rebuildAllBundleDependencies(monitor);
                             }
-                        }, shell );
+                        }, shell);
                     }
                     return true;
                 }
@@ -77,25 +74,25 @@
                     return false;
                 }
             }
-            catch ( Exception e )
+            catch (Exception e)
             {
-                SigilCore.error( "Failed to run caller", e );
+                SigilCore.error("Failed to run caller", e);
                 return false;
             }
         }
     }
 
-
-    private static int checkRebuild( Shell shell )
+    private static int checkRebuild(Shell shell)
     {
-        if ( SigilCore.getRoot().getProjects().isEmpty() )
+        if (SigilCore.getRoot().getProjects().isEmpty())
         {
             return IDialogConstants.NO_ID;
         }
         else
         {
             return OptionalPrompt.optionallyPromptWithCancel(
-                SigilCore.PREFERENCES_REBUILD_PROJECTS, "Rebuild", "Do you wish to rebuild all Sigil projects", shell );
+                SigilCore.PREFERENCES_REBUILD_PROJECTS, "Rebuild",
+                "Do you wish to rebuild all Sigil projects", shell);
         }
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourceReviewDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourceReviewDialog.java
index a5c2729..acabd9a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourceReviewDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourceReviewDialog.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.Collection;
 
 import org.apache.felix.sigil.common.model.IModelElement;
@@ -40,7 +39,6 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
 
-
 public class ResourceReviewDialog<T extends IModelElement> extends TitleAreaDialog
 {
 
@@ -49,80 +47,76 @@
 
     private TableViewer viewer;
 
-
-    public ResourceReviewDialog( Shell parentShell, String title, Collection<T> resources )
+    public ResourceReviewDialog(Shell parentShell, String title, Collection<T> resources)
     {
-        super( parentShell );
+        super(parentShell);
         this.title = title;
         this.resources = resources;
     }
 
-
     public Collection<T> getResources()
     {
         return resources;
     }
 
-
     @Override
-    protected Control createDialogArea( Composite parent )
+    protected Control createDialogArea(Composite parent)
     {
-        setTitle( title );
+        setTitle(title);
 
         // Create controls
-        Composite container = ( Composite ) super.createDialogArea( parent );
-        Composite composite = new Composite( container, SWT.NONE );
-        Table table = new Table( composite, SWT.BORDER | SWT.VIRTUAL );
+        Composite container = (Composite) super.createDialogArea(parent);
+        Composite composite = new Composite(container, SWT.NONE);
+        Table table = new Table(composite, SWT.BORDER | SWT.VIRTUAL);
 
-        final Button remove = new Button( composite, SWT.PUSH );
-        remove.setText( "Remove" );
-        remove.setEnabled( false );
+        final Button remove = new Button(composite, SWT.PUSH);
+        remove.setText("Remove");
+        remove.setEnabled(false);
 
-        remove.addSelectionListener( new SelectionAdapter()
+        remove.addSelectionListener(new SelectionAdapter()
         {
             @Override
-            public void widgetSelected( SelectionEvent e )
+            public void widgetSelected(SelectionEvent e)
             {
                 handleRemove();
             }
-        } );
+        });
 
-        viewer = new TableViewer( table );
-        viewer.setContentProvider( new DefaultTableProvider()
+        viewer = new TableViewer(table);
+        viewer.setContentProvider(new DefaultTableProvider()
         {
-            public Object[] getElements( Object inputElement )
+            public Object[] getElements(Object inputElement)
             {
-                return toArray( inputElement );
+                return toArray(inputElement);
             }
-        } );
+        });
 
-        viewer.setInput( resources );
-        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        viewer.setInput(resources);
+        viewer.addSelectionChangedListener(new ISelectionChangedListener()
         {
-            public void selectionChanged( SelectionChangedEvent event )
+            public void selectionChanged(SelectionChangedEvent event)
             {
-                remove.setEnabled( !event.getSelection().isEmpty() );
+                remove.setEnabled(!event.getSelection().isEmpty());
             }
-        } );
+        });
 
         // layout
-        composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        composite.setLayout( new GridLayout( 2, false ) );
-        GridData tableLayoutData = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 4 );
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        composite.setLayout(new GridLayout(2, false));
+        GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4);
         tableLayoutData.heightHint = 150;
-        table.setLayoutData( tableLayoutData );
+        table.setLayoutData(tableLayoutData);
 
         return container;
     }
 
-
     private void handleRemove()
     {
         ISelection s = viewer.getSelection();
-        if ( !s.isEmpty() )
+        if (!s.isEmpty())
         {
-            IStructuredSelection sel = ( IStructuredSelection ) s;
-            resources.remove( sel.getFirstElement() );
+            IStructuredSelection sel = (IStructuredSelection) s;
+            resources.remove(sel.getFirstElement());
             viewer.refresh();
         }
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourcesDialogHelper.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourcesDialogHelper.java
index 6ef3710..a9b1b3c 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourcesDialogHelper.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourcesDialogHelper.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.ArrayList;
 
 import java.util.Collection;
@@ -51,39 +50,39 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.progress.IJobRunnable;
 
-
 public class ResourcesDialogHelper
 {
 
     static final int UPDATE_BATCH_SIZE = 100;
 
-
-    public static BackgroundLoadingSelectionDialog<String> createClassSelectDialog( Shell shell, String title,
-        final ISigilProjectModel project, String selected, final String ifaceOrParentClass )
+    public static BackgroundLoadingSelectionDialog<String> createClassSelectDialog(
+        Shell shell, String title, final ISigilProjectModel project, String selected,
+        final String ifaceOrParentClass)
     {
-        final BackgroundLoadingSelectionDialog<String> dialog = new BackgroundLoadingSelectionDialog<String>( shell,
-            "Class Name", true );
+        final BackgroundLoadingSelectionDialog<String> dialog = new BackgroundLoadingSelectionDialog<String>(
+            shell, "Class Name", true);
 
         IJobRunnable job = new IJobRunnable()
         {
-            public IStatus run( IProgressMonitor monitor )
+            public IStatus run(IProgressMonitor monitor)
             {
                 try
                 {
-                    for ( IJavaElement e : JavaHelper.findTypes( project.getJavaModel(),
-                        IJavaElement.PACKAGE_FRAGMENT ) )
+                    for (IJavaElement e : JavaHelper.findTypes(project.getJavaModel(),
+                        IJavaElement.PACKAGE_FRAGMENT))
                     {
-                        IPackageFragment root = ( IPackageFragment ) e;
-                        if ( project.isInBundleClasspath( root ) )
+                        IPackageFragment root = (IPackageFragment) e;
+                        if (project.isInBundleClasspath(root))
                         {
-                            for ( IJavaElement e1 : JavaHelper.findTypes( root, IJavaElement.COMPILATION_UNIT,
-                                IJavaElement.CLASS_FILE ) )
+                            for (IJavaElement e1 : JavaHelper.findTypes(root,
+                                IJavaElement.COMPILATION_UNIT, IJavaElement.CLASS_FILE))
                             {
-                                ITypeRoot typeRoot = ( ITypeRoot ) e1;
-                                IType type = ( IType ) JavaHelper.findType( typeRoot, IJavaElement.TYPE );
-                                if ( JavaHelper.isAssignableTo( ifaceOrParentClass, type ) )
+                                ITypeRoot typeRoot = (ITypeRoot) e1;
+                                IType type = (IType) JavaHelper.findType(typeRoot,
+                                    IJavaElement.TYPE);
+                                if (JavaHelper.isAssignableTo(ifaceOrParentClass, type))
                                 {
-                                    dialog.addElement( type.getFullyQualifiedName() );
+                                    dialog.addElement(type.getFullyQualifiedName());
                                 }
                             }
                         }
@@ -91,7 +90,7 @@
 
                     return Status.OK_STATUS;
                 }
-                catch ( JavaModelException e )
+                catch (JavaModelException e)
                 {
                     return e.getStatus();
                 }
@@ -99,88 +98,89 @@
 
         };
 
-        dialog.addBackgroundJob( "Scanning for activators in project", job );
+        dialog.addBackgroundJob("Scanning for activators in project", job);
 
         return dialog;
     }
 
-
-    public static NewResourceSelectionDialog<IPackageExport> createImportDialog( Shell shell, String title,
-        ISigilProjectModel sigil, final IPackageImport selected, final Collection<IPackageImport> existing )
+    public static NewResourceSelectionDialog<IPackageExport> createImportDialog(
+        Shell shell, String title, ISigilProjectModel sigil,
+        final IPackageImport selected, final Collection<IPackageImport> existing)
     {
         final Set<String> existingNames = new HashSet<String>();
 
-        for ( IPackageImport existingImport : existing )
+        for (IPackageImport existingImport : existing)
         {
-            existingNames.add( existingImport.getPackageName() );
+            existingNames.add(existingImport.getPackageName());
         }
 
         final NewResourceSelectionDialog<IPackageExport> dialog = new NewResourceSelectionDialog<IPackageExport>(
-            shell, "Package Name:", false );
+            shell, "Package Name:", false);
 
-        dialog.setFilter( new IFilter<IPackageModelElement>()
+        dialog.setFilter(new IFilter<IPackageModelElement>()
         {
-            public boolean select( IPackageModelElement element )
+            public boolean select(IPackageModelElement element)
             {
-                return !existingNames.contains( element.getPackageName() );
+                return !existingNames.contains(element.getPackageName());
             }
-        } );
+        });
 
-        dialog.setComparator( new Comparator<IPackageExport>()
+        dialog.setComparator(new Comparator<IPackageExport>()
         {
-            public int compare( IPackageExport o1, IPackageExport o2 )
+            public int compare(IPackageExport o1, IPackageExport o2)
             {
-                return o1.compareTo( o2 );
+                return o1.compareTo(o2);
             }
-        } );
+        });
 
-        dialog.setDescriptor( new IElementDescriptor<IPackageExport>()
+        dialog.setDescriptor(new IElementDescriptor<IPackageExport>()
         {
-            public String getLabel( IPackageExport element )
+            public String getLabel(IPackageExport element)
             {
-                return getName( element ) + " (" + element.getVersion().toString() + ")";
+                return getName(element) + " (" + element.getVersion().toString() + ")";
             }
 
-
-            public String getName( IPackageExport element )
+            public String getName(IPackageExport element)
             {
                 return element.getPackageName();
             }
-        } );
+        });
 
-        dialog.setLabelProvider( new WrappedContentProposalLabelProvider<IPackageExport>( dialog.getDescriptor() ) );
+        dialog.setLabelProvider(new WrappedContentProposalLabelProvider<IPackageExport>(
+            dialog.getDescriptor()));
 
-        if ( selected != null )
+        if (selected != null)
         {
-            dialog.setSelectedName( selected.getPackageName() );
-            dialog.setVersions( selected.getVersions() );
-            dialog.setOptional( selected.isOptional() );
+            dialog.setSelectedName(selected.getPackageName());
+            dialog.setVersions(selected.getVersions());
+            dialog.setOptional(selected.isOptional());
         }
 
-        IJobRunnable job = new ExportedPackageFinder( sigil, dialog );
-        dialog.addBackgroundJob( "Scanning for exports in workspace", job );
+        IJobRunnable job = new ExportedPackageFinder(sigil, dialog);
+        dialog.addBackgroundJob("Scanning for exports in workspace", job);
 
         return dialog;
     }
 
-
-    public static NewPackageExportDialog createNewExportDialog( Shell shell, String title,
-        final IPackageExport selected, final ISigilProjectModel project, boolean multiSelect )
+    public static NewPackageExportDialog createNewExportDialog(Shell shell, String title,
+        final IPackageExport selected, final ISigilProjectModel project,
+        boolean multiSelect)
     {
         IFilter<IJavaElement> selectFilter = new IFilter<IJavaElement>()
         {
-            public boolean select( IJavaElement e )
+            public boolean select(IJavaElement e)
             {
-                if ( selected != null && e.getElementName().equals( selected.getPackageName() ) )
+                if (selected != null
+                    && e.getElementName().equals(selected.getPackageName()))
                 {
                     return true;
                 }
 
-                if ( e.getElementName().trim().length() > 0 && isLocal( e ) )
+                if (e.getElementName().trim().length() > 0 && isLocal(e))
                 {
-                    for ( IPackageExport p : project.getBundle().getBundleInfo().getExports() )
+                    for (IPackageExport p : project.getBundle().getBundleInfo().getExports())
                     {
-                        if ( p.getPackageName().equals( e.getElementName() ) )
+                        if (p.getPackageName().equals(e.getElementName()))
                         {
                             return false;
                         }
@@ -194,150 +194,151 @@
                 }
             }
 
-
-            private boolean isLocal( IJavaElement java )
+            private boolean isLocal(IJavaElement java)
             {
                 try
                 {
-                    switch ( java.getElementType() )
+                    switch (java.getElementType())
                     {
                         case IJavaElement.PACKAGE_FRAGMENT:
-                            IPackageFragment fragment = ( IPackageFragment ) java;
+                            IPackageFragment fragment = (IPackageFragment) java;
                             return fragment.containsJavaResources();
                         default:
-                            throw new IllegalStateException( "Unexpected resource type " + java );
+                            throw new IllegalStateException("Unexpected resource type "
+                                + java);
                     }
                 }
-                catch ( JavaModelException e )
+                catch (JavaModelException e)
                 {
-                    SigilCore.error( "Failed to inspect java element ", e );
+                    SigilCore.error("Failed to inspect java element ", e);
                     return false;
                 }
             }
 
         };
 
-        final NewPackageExportDialog dialog = new NewPackageExportDialog( shell, multiSelect );
-        dialog.setFilter( selectFilter );
+        final NewPackageExportDialog dialog = new NewPackageExportDialog(shell,
+            multiSelect);
+        dialog.setFilter(selectFilter);
 
-        dialog.setProjectVersion( project.getVersion() );
-        if ( selected != null )
+        dialog.setProjectVersion(project.getVersion());
+        if (selected != null)
         {
-            dialog.setSelectedName( selected.getPackageName() );
-            dialog.setVersion( selected.getRawVersion() );
+            dialog.setSelectedName(selected.getPackageName());
+            dialog.setVersion(selected.getRawVersion());
         }
 
         IJobRunnable job = new IJobRunnable()
         {
-            public IStatus run( IProgressMonitor monitor )
+            public IStatus run(IProgressMonitor monitor)
             {
                 try
                 {
-                    ArrayList<IPackageFragment> list = new ArrayList<IPackageFragment>( UPDATE_BATCH_SIZE );
-                    for ( IJavaElement e : JavaHelper.findTypes( project.getJavaModel(),
-                        IJavaElement.PACKAGE_FRAGMENT ) )
+                    ArrayList<IPackageFragment> list = new ArrayList<IPackageFragment>(
+                        UPDATE_BATCH_SIZE);
+                    for (IJavaElement e : JavaHelper.findTypes(project.getJavaModel(),
+                        IJavaElement.PACKAGE_FRAGMENT))
                     {
-                        IPackageFragment root = ( IPackageFragment ) e;
-                        if ( project.isInBundleClasspath( root ) )
+                        IPackageFragment root = (IPackageFragment) e;
+                        if (project.isInBundleClasspath(root))
                         {
-                            list.add( root );
-                            if ( list.size() >= UPDATE_BATCH_SIZE )
+                            list.add(root);
+                            if (list.size() >= UPDATE_BATCH_SIZE)
                             {
-                                dialog.addElements( list );
+                                dialog.addElements(list);
                                 list.clear();
                             }
                         }
                     }
-                    if ( !list.isEmpty() )
+                    if (!list.isEmpty())
                     {
-                        dialog.addElements( list );
+                        dialog.addElements(list);
                     }
                     return Status.OK_STATUS;
                 }
-                catch ( JavaModelException e )
+                catch (JavaModelException e)
                 {
                     return e.getStatus();
                 }
             }
         };
 
-        dialog.addBackgroundJob( "Scanning for packages in project", job );
+        dialog.addBackgroundJob("Scanning for packages in project", job);
 
         return dialog;
     }
 
-
-    public static NewResourceSelectionDialog<IBundleModelElement> createRequiredBundleDialog( Shell shell,
-        String title, final ISigilProjectModel sigil, final IRequiredBundle selected,
-        final Collection<IRequiredBundle> existing )
+    public static NewResourceSelectionDialog<IBundleModelElement> createRequiredBundleDialog(
+        Shell shell, String title, final ISigilProjectModel sigil,
+        final IRequiredBundle selected, final Collection<IRequiredBundle> existing)
     {
         final Set<String> existingNames = new HashSet<String>();
-        for ( IRequiredBundle existingBundle : existing )
+        for (IRequiredBundle existingBundle : existing)
         {
-            existingNames.add( existingBundle.getSymbolicName() );
+            existingNames.add(existingBundle.getSymbolicName());
         }
 
         final NewResourceSelectionDialog<IBundleModelElement> dialog = new NewResourceSelectionDialog<IBundleModelElement>(
-            shell, "Bundle:", false );
+            shell, "Bundle:", false);
 
-        dialog.setDescriptor( new IElementDescriptor<IBundleModelElement>()
+        dialog.setDescriptor(new IElementDescriptor<IBundleModelElement>()
         {
-            public String getLabel( IBundleModelElement element )
+            public String getLabel(IBundleModelElement element)
             {
-                return getName( element ) + " (" + element.getVersion() + ")";
+                return getName(element) + " (" + element.getVersion() + ")";
             }
 
-
-            public String getName( IBundleModelElement element )
+            public String getName(IBundleModelElement element)
             {
                 return element.getSymbolicName();
             }
-        } );
+        });
 
-        dialog
-            .setLabelProvider( new WrappedContentProposalLabelProvider<IBundleModelElement>( dialog.getDescriptor() ) );
+        dialog.setLabelProvider(new WrappedContentProposalLabelProvider<IBundleModelElement>(
+            dialog.getDescriptor()));
 
-        dialog.setFilter( new IFilter<IBundleModelElement>()
+        dialog.setFilter(new IFilter<IBundleModelElement>()
         {
-            public boolean select( IBundleModelElement element )
+            public boolean select(IBundleModelElement element)
             {
-                return !existingNames.contains( element.getSymbolicName() );
+                return !existingNames.contains(element.getSymbolicName());
             }
-        } );
+        });
 
-        dialog.setComparator( new Comparator<IBundleModelElement>()
+        dialog.setComparator(new Comparator<IBundleModelElement>()
         {
-            public int compare( IBundleModelElement o1, IBundleModelElement o2 )
+            public int compare(IBundleModelElement o1, IBundleModelElement o2)
             {
-                return o1.getSymbolicName().compareTo( o2.getSymbolicName() );
+                return o1.getSymbolicName().compareTo(o2.getSymbolicName());
             }
-        } );
+        });
 
-        if ( selected != null )
+        if (selected != null)
         {
-            dialog.setSelectedName( selected.getSymbolicName() );
-            dialog.setVersions( selected.getVersions() );
-            dialog.setOptional( selected.isOptional() );
+            dialog.setSelectedName(selected.getSymbolicName());
+            dialog.setVersions(selected.getVersions());
+            dialog.setOptional(selected.isOptional());
         }
 
         IJobRunnable job = new IJobRunnable()
         {
-            public IStatus run( final IProgressMonitor monitor )
+            public IStatus run(final IProgressMonitor monitor)
             {
-                final List<IBundleModelElement> bundles = new ArrayList<IBundleModelElement>( UPDATE_BATCH_SIZE );
+                final List<IBundleModelElement> bundles = new ArrayList<IBundleModelElement>(
+                    UPDATE_BATCH_SIZE);
                 final IModelWalker walker = new IModelWalker()
                 {
                     //int count = 0;
-                    public boolean visit( IModelElement element )
+                    public boolean visit(IModelElement element)
                     {
-                        if ( element instanceof IBundleModelElement )
+                        if (element instanceof IBundleModelElement)
                         {
-                            IBundleModelElement b = ( IBundleModelElement ) element;
-                            bundles.add( b );
+                            IBundleModelElement b = (IBundleModelElement) element;
+                            bundles.add(b);
 
-                            if ( bundles.size() >= UPDATE_BATCH_SIZE )
+                            if (bundles.size() >= UPDATE_BATCH_SIZE)
                             {
-                                dialog.addElements( bundles );
+                                dialog.addElements(bundles);
                                 bundles.clear();
                             }
                             // no need to recurse further.
@@ -346,16 +347,16 @@
                         return !monitor.isCanceled();
                     }
                 };
-                SigilCore.getRepositoryManager( sigil ).visit( walker );
-                if ( !bundles.isEmpty() )
+                SigilCore.getRepositoryManager(sigil).visit(walker);
+                if (!bundles.isEmpty())
                 {
-                    dialog.addElements( bundles );
+                    dialog.addElements(bundles);
                 }
                 return Status.OK_STATUS;
             }
         };
 
-        dialog.addBackgroundJob( "Scanning for bundles in workspace", job );
+        dialog.addBackgroundJob("Scanning for bundles in workspace", job);
 
         return dialog;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/SingletonSelection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/SingletonSelection.java
index 6a83e37..2784d35 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/SingletonSelection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/SingletonSelection.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
@@ -27,53 +26,44 @@
 
 import org.eclipse.jface.viewers.IStructuredSelection;
 
-
 @SuppressWarnings("unchecked")
 public class SingletonSelection implements IStructuredSelection
 {
 
     private final Object singleton;
 
-
-    public SingletonSelection( Object singleton )
+    public SingletonSelection(Object singleton)
     {
         this.singleton = singleton;
     }
 
-
     public Object getFirstElement()
     {
         return singleton;
     }
 
-
     public Iterator iterator()
     {
-        return Collections.singleton( singleton ).iterator();
+        return Collections.singleton(singleton).iterator();
     }
 
-
     public int size()
     {
         return 1;
     }
 
-
     public Object[] toArray()
     {
-        return new Object[]
-            { singleton };
+        return new Object[] { singleton };
     }
 
-
     public List toList()
     {
-        ArrayList list = new ArrayList( 1 );
-        list.add( singleton );
+        ArrayList list = new ArrayList(1);
+        list.add(singleton);
         return list;
     }
 
-
     public boolean isEmpty()
     {
         return false;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/UIHelper.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/UIHelper.java
index a79697a..347a6b7 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/UIHelper.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/UIHelper.java
@@ -2,25 +2,27 @@
 
 public class UIHelper
 {
-    public static <T> IElementDescriptor<T> getDefaultElementDescriptor() {
+    public static <T> IElementDescriptor<T> getDefaultElementDescriptor()
+    {
         return new IElementDescriptor<T>()
         {
-            public String getLabel( T element )
+            public String getLabel(T element)
             {
                 return element == null ? "null" : element.toString();
             }
 
-
-            public String getName( T element )
+            public String getName(T element)
             {
-                return getLabel( element );
+                return getLabel(element);
             }
         };
     }
-    
-    public static <T> IFilter<T> getDefaultFilter() {
-        return new IFilter<T> () {
-            public boolean select( T element )
+
+    public static <T> IFilter<T> getDefaultFilter()
+    {
+        return new IFilter<T>()
+        {
+            public boolean select(T element)
             {
                 return true;
             }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposal.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposal.java
index aafb2c0..ec44762 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposal.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposal.java
@@ -19,60 +19,51 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import org.eclipse.jface.fieldassist.IContentProposal;
 
-
 public class WrappedContentProposal<T> implements IContentProposal
 {
 
     private final T element;
     private final IElementDescriptor<? super T> descriptor;
 
-
-    private WrappedContentProposal( T element, IElementDescriptor<? super T> descriptor )
+    private WrappedContentProposal(T element, IElementDescriptor<? super T> descriptor)
     {
         this.element = element;
         this.descriptor = descriptor;
     }
 
-
-    public static <T> WrappedContentProposal<T> newInstance( T element, IElementDescriptor<? super T> descriptor )
+    public static <T> WrappedContentProposal<T> newInstance(T element,
+        IElementDescriptor<? super T> descriptor)
     {
-        return new WrappedContentProposal<T>( element, descriptor );
+        return new WrappedContentProposal<T>(element, descriptor);
     }
 
-
     public String getContent()
     {
-        return descriptor.getName( element );
+        return descriptor.getName(element);
     }
 
-
     public int getCursorPosition()
     {
         return 0;
     }
 
-
     public String getDescription()
     {
         return null;
     }
 
-
     public String getLabel()
     {
-        return descriptor.getLabel( element );
+        return descriptor.getLabel(element);
     }
 
-
     public T getElement()
     {
         return element;
     }
 
-
     @Override
     public String toString()
     {
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposalLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposalLabelProvider.java
index b4c4b67..9e1d46f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposalLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposalLabelProvider.java
@@ -19,53 +19,47 @@
 
 package org.apache.felix.sigil.eclipse.ui.util;
 
-
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;
 
-
 public class WrappedContentProposalLabelProvider<E> extends LabelProvider
 {
 
     private final IElementDescriptor<? super E> descriptor;
     private final ModelLabelProvider projectLabelProvider;
 
-
-    public WrappedContentProposalLabelProvider( IElementDescriptor<? super E> descriptor )
+    public WrappedContentProposalLabelProvider(IElementDescriptor<? super E> descriptor)
     {
         this.descriptor = descriptor;
         projectLabelProvider = new ModelLabelProvider();
     }
 
-
     @SuppressWarnings("unchecked")
-    private E adapt( Object element )
+    private E adapt(Object element)
     {
         E result;
-        if ( element instanceof WrappedContentProposal<?> )
+        if (element instanceof WrappedContentProposal<?>)
         {
-            WrappedContentProposal<?> proposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<?> ) element;
-            result = ( E ) proposal.getElement();
+            WrappedContentProposal<?> proposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<?>) element;
+            result = (E) proposal.getElement();
         }
         else
         {
-            result = ( E ) element;
+            result = (E) element;
         }
         return result;
     }
 
-
     @Override
-    public Image getImage( Object element )
+    public Image getImage(Object element)
     {
-        Object value = adapt( element );
-        return projectLabelProvider.getImage( value );
+        Object value = adapt(element);
+        return projectLabelProvider.getImage(value);
     }
 
-
     @Override
-    public String getText( Object element )
+    public String getText(Object element)
     {
-        return descriptor.getLabel( adapt( element ) );
+        return descriptor.getLabel(adapt(element));
     }
 }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizard.java
index 07fdd73..3284e4e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizard.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.wizard.project;
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.ui.internal.wizard.SigilNewResourceWizard;
 import org.eclipse.core.resources.IFile;
@@ -41,7 +40,6 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
 
-
 /**
  * @author dave
  *
@@ -54,50 +52,48 @@
 
     private String name;
 
-    public static final IPath SIGIL_PROJECT_PATH = new Path( SigilCore.SIGIL_PROJECT_FILE );
+    public static final IPath SIGIL_PROJECT_PATH = new Path(SigilCore.SIGIL_PROJECT_FILE);
     private IConfigurationElement config;
 
-
-    public void init( IWorkbench workbench, IStructuredSelection currentSelection )
+    public void init(IWorkbench workbench, IStructuredSelection currentSelection)
     {
-        super.init( workbench, currentSelection );
+        super.init(workbench, currentSelection);
 
         firstPage = new SigilProjectWizardFirstPage();
-        firstPage.setInitialProjectName( name );
-        secondPage = new SigilProjectWizardSecondPage( firstPage );
+        firstPage.setInitialProjectName(name);
+        secondPage = new SigilProjectWizardSecondPage(firstPage);
 
-        addPage( firstPage );
-        addPage( secondPage );
+        addPage(firstPage);
+        addPage(secondPage);
     }
 
-
-    private void finishPage( IProgressMonitor monitor ) throws CoreException, InterruptedException
+    private void finishPage(IProgressMonitor monitor) throws CoreException,
+        InterruptedException
     {
-        secondPage.performFinish( monitor );
+        secondPage.performFinish(monitor);
 
         IProject newProject = firstPage.getProjectHandle();
 
-        if ( newProject != null && newProject.exists() )
+        if (newProject != null && newProject.exists())
         {
-            IFile file = newProject.getFile( SigilProjectWizard.SIGIL_PROJECT_PATH );
+            IFile file = newProject.getFile(SigilProjectWizard.SIGIL_PROJECT_PATH);
 
-            selectRevealAndShow( file );
+            selectRevealAndShow(file);
 
             // don't do this check for now - see FELIX-1924
-//            new Job( "Check OSGi Install" )
-//            {
-//                @Override
-//                protected IStatus run( IProgressMonitor monitor )
-//                {
-//                    // prompt for osgi home if not already set.
-//                    SigilCore.getInstallManager().getDefaultInstall();
-//                    return Status.OK_STATUS;
-//                }
-//            }.schedule();
+            //            new Job( "Check OSGi Install" )
+            //            {
+            //                @Override
+            //                protected IStatus run( IProgressMonitor monitor )
+            //                {
+            //                    // prompt for osgi home if not already set.
+            //                    SigilCore.getInstallManager().getDefaultInstall();
+            //                    return Status.OK_STATUS;
+            //                }
+            //            }.schedule();
         }
     }
 
-
     /* (non-Javadoc)
      * @see org.eclipse.jface.wizard.Wizard#performFinish()
      */
@@ -108,46 +104,43 @@
 
         IWorkspaceRunnable op = new IWorkspaceRunnable()
         {
-            public void run( IProgressMonitor monitor ) throws CoreException
+            public void run(IProgressMonitor monitor) throws CoreException
             {
                 try
                 {
-                    finishPage( monitor );
+                    finishPage(monitor);
                 }
-                catch ( InterruptedException e )
+                catch (InterruptedException e)
                 {
-                    throw new OperationCanceledException( e.getMessage() );
+                    throw new OperationCanceledException(e.getMessage());
                 }
             }
         };
 
         try
         {
-            workspace.run( op, Job.getJobManager().createProgressGroup() );
+            workspace.run(op, Job.getJobManager().createProgressGroup());
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to complete project wizard", e );
+            SigilCore.error("Failed to complete project wizard", e);
             return false;
         }
 
-        BasicNewProjectResourceWizard.updatePerspective( config );
+        BasicNewProjectResourceWizard.updatePerspective(config);
         return true;
     }
 
-
-    public void setName( String name )
+    public void setName(String name)
     {
         this.name = name;
     }
 
-
     public String getName()
     {
         return name;
     }
 
-
     @Override
     public boolean performCancel()
     {
@@ -155,9 +148,8 @@
         return super.performCancel();
     }
 
-
-    public void setInitializationData( IConfigurationElement config, String propertyName, Object data )
-        throws CoreException
+    public void setInitializationData(IConfigurationElement config, String propertyName,
+        Object data) throws CoreException
     {
         this.config = config;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardFirstPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardFirstPage.java
index ec7e27a..19fdd13 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardFirstPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardFirstPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.wizard.project;
 
-
 import org.apache.felix.sigil.common.osgi.VersionTable;
 import org.apache.felix.sigil.eclipse.ui.internal.views.RepositoryViewPart;
 import org.eclipse.core.resources.IWorkspace;
@@ -41,7 +40,6 @@
 import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
 import org.osgi.framework.Version;
 
-
 /**
  * @author dave
  *
@@ -50,7 +48,7 @@
 {
 
     private volatile String description = "";
-    private volatile Version version = VersionTable.getVersion( 1, 0, 0 );
+    private volatile Version version = VersionTable.getVersion(1, 0, 0);
     private volatile String vendor = "";
     private volatile String name = "";
 
@@ -59,26 +57,24 @@
     private Text txtVendor;
     private Text txtName;
 
-
     public SigilProjectWizardFirstPage()
     {
-        super( "newSigilProjectPage" );
-        setTitle( "Sigil Project" );
-        setDescription( "Create a new Sigil project" );
-        setImageDescriptor( ImageDescriptor.createFromFile( RepositoryViewPart.class, "/icons/logo64x64.gif" ) );
+        super("newSigilProjectPage");
+        setTitle("Sigil Project");
+        setDescription("Create a new Sigil project");
+        setImageDescriptor(ImageDescriptor.createFromFile(RepositoryViewPart.class,
+            "/icons/logo64x64.gif"));
     }
 
-
     public boolean isInWorkspace()
     {
         IWorkspace workspace = ResourcesPlugin.getWorkspace();
 
         IPath defaultDefaultLocation = workspace.getRoot().getLocation();
 
-        return defaultDefaultLocation.isPrefixOf( getLocationPath() );
+        return defaultDefaultLocation.isPrefixOf(getLocationPath());
     }
 
-
     @Override
     public boolean isPageComplete()
     {
@@ -86,54 +82,56 @@
         return result;
     }
 
-
     @Override
-    public void createControl( Composite parent )
+    public void createControl(Composite parent)
     {
         FieldDecoration infoDecor = FieldDecorationRegistry.getDefault().getFieldDecoration(
-            FieldDecorationRegistry.DEC_INFORMATION );
+            FieldDecorationRegistry.DEC_INFORMATION);
 
         // Create controls
-        super.createControl( parent );
-        Composite control = ( Composite ) getControl();
+        super.createControl(parent);
+        Composite control = (Composite) getControl();
 
-        Group grpProjectSettings = new Group( control, SWT.NONE );
-        grpProjectSettings.setText( "Project Settings" );
+        Group grpProjectSettings = new Group(control, SWT.NONE);
+        grpProjectSettings.setText("Project Settings");
 
-        new Label( grpProjectSettings, SWT.NONE ).setText( "Version:" );
-        txtVersion = new Text( grpProjectSettings, SWT.BORDER );
+        new Label(grpProjectSettings, SWT.NONE).setText("Version:");
+        txtVersion = new Text(grpProjectSettings, SWT.BORDER);
 
-        new Label( grpProjectSettings, SWT.NONE ).setText( "Name:" );
-        txtName = new Text( grpProjectSettings, SWT.BORDER );
+        new Label(grpProjectSettings, SWT.NONE).setText("Name:");
+        txtName = new Text(grpProjectSettings, SWT.BORDER);
 
-        ControlDecoration txtNameDecor = new ControlDecoration( txtName, SWT.LEFT | SWT.CENTER );
-        txtNameDecor.setImage( infoDecor.getImage() );
-        txtNameDecor.setDescriptionText( "Defines a human-readable name for the bundle" );
+        ControlDecoration txtNameDecor = new ControlDecoration(txtName, SWT.LEFT
+            | SWT.CENTER);
+        txtNameDecor.setImage(infoDecor.getImage());
+        txtNameDecor.setDescriptionText("Defines a human-readable name for the bundle");
 
-        new Label( grpProjectSettings, SWT.NONE ).setText( "Description:" );
-        txtDescription = new Text( grpProjectSettings, SWT.BORDER );
+        new Label(grpProjectSettings, SWT.NONE).setText("Description:");
+        txtDescription = new Text(grpProjectSettings, SWT.BORDER);
 
-        ControlDecoration txtDescDecor = new ControlDecoration( txtDescription, SWT.LEFT | SWT.CENTER );
-        txtDescDecor.setImage( infoDecor.getImage() );
-        txtDescDecor.setDescriptionText( "Defines a short human-readable description for the bundle" );
+        ControlDecoration txtDescDecor = new ControlDecoration(txtDescription, SWT.LEFT
+            | SWT.CENTER);
+        txtDescDecor.setImage(infoDecor.getImage());
+        txtDescDecor.setDescriptionText("Defines a short human-readable description for the bundle");
 
-        new Label( grpProjectSettings, SWT.NONE ).setText( "Provider:" );
-        txtVendor = new Text( grpProjectSettings, SWT.BORDER );
+        new Label(grpProjectSettings, SWT.NONE).setText("Provider:");
+        txtVendor = new Text(grpProjectSettings, SWT.BORDER);
 
-        ControlDecoration txtVendorDecor = new ControlDecoration( txtVendor, SWT.LEFT | SWT.CENTER );
-        txtVendorDecor.setImage( infoDecor.getImage() );
-        txtVendorDecor.setDescriptionText( "The name of the company, organisation or individual providing the bundle" );
+        ControlDecoration txtVendorDecor = new ControlDecoration(txtVendor, SWT.LEFT
+            | SWT.CENTER);
+        txtVendorDecor.setImage(infoDecor.getImage());
+        txtVendorDecor.setDescriptionText("The name of the company, organisation or individual providing the bundle");
 
         // Set values
-        txtDescription.setText( description );
-        txtVersion.setText( version.toString() );
-        txtVendor.setText( vendor );
-        txtName.setText( name );
+        txtDescription.setText(description);
+        txtVersion.setText(version.toString());
+        txtVendor.setText(vendor);
+        txtName.setText(name);
 
         // Add listeners
         ModifyListener txtModListener = new ModifyListener()
         {
-            public void modifyText( ModifyEvent e )
+            public void modifyText(ModifyEvent e)
             {
                 description = txtDescription.getText();
                 vendor = txtVendor.getText();
@@ -142,59 +140,54 @@
                 validateSettings();
             }
         };
-        txtDescription.addModifyListener( txtModListener );
-        txtVersion.addModifyListener( txtModListener );
-        txtVendor.addModifyListener( txtModListener );
-        txtName.addModifyListener( txtModListener );
+        txtDescription.addModifyListener(txtModListener);
+        txtVersion.addModifyListener(txtModListener);
+        txtVendor.addModifyListener(txtModListener);
+        txtName.addModifyListener(txtModListener);
 
         // Layout
-        control.setLayout( new GridLayout() );
-        grpProjectSettings.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        grpProjectSettings.setLayout( new GridLayout( 2, false ) );
-        txtDescription.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        txtVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        txtVendor.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
-        txtName.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+        control.setLayout(new GridLayout());
+        grpProjectSettings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        grpProjectSettings.setLayout(new GridLayout(2, false));
+        txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        txtVendor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        txtName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
     }
 
-
     private void validateSettings()
     {
         try
         {
-            version = VersionTable.getVersion( txtVersion.getText() );
+            version = VersionTable.getVersion(txtVersion.getText());
         }
-        catch ( IllegalArgumentException e )
+        catch (IllegalArgumentException e)
         {
             version = null;
-            setErrorMessage( "Invalid version" );
-            setPageComplete( false );
+            setErrorMessage("Invalid version");
+            setPageComplete(false);
             return;
         }
 
-        setErrorMessage( null );
-        setPageComplete( true );
+        setErrorMessage(null);
+        setPageComplete(true);
     }
 
-
     public Version getVersion()
     {
         return version;
     }
 
-
     public String getVendor()
     {
         return vendor;
     }
 
-
     public String getDescription()
     {
         return description;
     }
 
-
     public String getName()
     {
         return name;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardSecondPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardSecondPage.java
index 3ab5b22..90c434a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardSecondPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardSecondPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.wizard.project;
 
-
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -48,7 +47,6 @@
 import org.eclipse.jdt.ui.wizards.JavaCapabilityConfigurationPage;
 import org.osgi.framework.Version;
 
-
 /**
  * @author dave
  *
@@ -61,18 +59,16 @@
     private URI currentProjectLocation;
     private boolean created;
 
-
-    public SigilProjectWizardSecondPage( SigilProjectWizardFirstPage firstPage )
+    public SigilProjectWizardSecondPage(SigilProjectWizardFirstPage firstPage)
     {
         this.firstPage = firstPage;
     }
 
-
     @Override
-    public void setVisible( boolean visible )
+    public void setVisible(boolean visible)
     {
-        super.setVisible( visible );
-        if ( visible )
+        super.setVisible(visible);
+        if (visible)
         {
             changeToNewProject();
         }
@@ -82,69 +78,66 @@
         }
     }
 
-
     @Override
     protected boolean useNewSourcePage()
     {
         return true;
     }
 
-
-    protected void performFinish( IProgressMonitor monitor ) throws CoreException, InterruptedException
+    protected void performFinish(IProgressMonitor monitor) throws CoreException,
+        InterruptedException
     {
         changeToNewProject();
-        updateProject( monitor );
+        updateProject(monitor);
     }
 
-
     private void changeToNewProject()
     {
-        if ( !created )
+        if (!created)
         {
             IWorkspace workspace = ResourcesPlugin.getWorkspace();
 
             IWorkspaceRunnable op = new IWorkspaceRunnable()
             {
-                public void run( IProgressMonitor monitor ) throws CoreException
+                public void run(IProgressMonitor monitor) throws CoreException
                 {
                     try
                     {
-                        updateProject( monitor );
+                        updateProject(monitor);
                     }
-                    catch ( InterruptedException e )
+                    catch (InterruptedException e)
                     {
-                        throw new OperationCanceledException( e.getMessage() );
+                        throw new OperationCanceledException(e.getMessage());
                     }
                 }
             };
 
             try
             {
-                workspace.run( op, Job.getJobManager().createProgressGroup() );
-                setErrorMessage( null );
-                setPageComplete( true );
+                workspace.run(op, Job.getJobManager().createProgressGroup());
+                setErrorMessage(null);
+                setPageComplete(true);
                 created = true;
             }
-            catch ( CoreException e )
+            catch (CoreException e)
             {
-                SigilCore.error( "Failed to run workspace job", e );
+                SigilCore.error("Failed to run workspace job", e);
             }
         }
     }
 
-
     private void removeProject()
     {
-        if ( currentProject == null || !currentProject.exists() )
+        if (currentProject == null || !currentProject.exists())
         {
             return;
         }
 
         IWorkspaceRunnable op = new IWorkspaceRunnable()
         {
-            public void run( IProgressMonitor monitor ) throws CoreException
+            public void run(IProgressMonitor monitor) throws CoreException
             {
-                doRemoveProject( monitor );
+                doRemoveProject(monitor);
             }
         };
 
@@ -152,11 +145,11 @@
 
         try
         {
-            workspace.run( op, Job.getJobManager().createProgressGroup() );
+            workspace.run(op, Job.getJobManager().createProgressGroup());
         }
-        catch ( CoreException e )
+        catch (CoreException e)
         {
-            SigilCore.error( "Failed to run workspace job", e );
+            SigilCore.error("Failed to run workspace job", e);
         }
         finally
         {
@@ -164,8 +157,8 @@
         }
     }
 
-
-    private void updateProject( IProgressMonitor monitor ) throws CoreException, InterruptedException
+    private void updateProject(IProgressMonitor monitor) throws CoreException,
+        InterruptedException
     {
         currentProject = firstPage.getProjectHandle();
         currentProjectLocation = getProjectLocationURI();
@@ -175,58 +168,58 @@
         String vendor = firstPage.getVendor();
         String name = firstPage.getName();
 
-        createProject( currentProject, currentProjectLocation, monitor );
+        createProject(currentProject, currentProjectLocation, monitor);
 
         IPath src = createSourcePath();
 
         IPath output = getOutputLocation();
 
-        if ( output.segmentCount() == 0 )
+        if (output.segmentCount() == 0)
         {
-            output = new Path( currentProject.getName() ).append( "build" ).append( "classes" );
+            output = new Path(currentProject.getName()).append("build").append("classes");
         }
 
-        IClasspathEntry[] entries = getProjectClassPath( src );
+        IClasspathEntry[] entries = getProjectClassPath(src);
 
-        SigilCore.makeSigilProject( currentProject, monitor );
+        SigilCore.makeSigilProject(currentProject, monitor);
 
-        init( JavaCore.create( currentProject ), output.makeRelative(), entries, false );
+        init(JavaCore.create(currentProject), output.makeRelative(), entries, false);
 
-        configureJavaProject( new SubProgressMonitor( monitor, 3 ) );
+        configureJavaProject(new SubProgressMonitor(monitor, 3));
 
-        configureSigilProject( currentProject, description, projectVersion, vendor, name, src, monitor );
+        configureSigilProject(currentProject, description, projectVersion, vendor, name,
+            src, monitor);
     }
 
-
     private IPath createSourcePath() throws CoreException
     {
         IPath projectPath = currentProject.getFullPath();
-        IPath src = new Path( "src" );
-        IFolder f = currentProject.getFolder( src );
-        if ( !f.getLocation().toFile().exists() )
+        IPath src = new Path("src");
+        IFolder f = currentProject.getFolder(src);
+        if (!f.getLocation().toFile().exists())
         {
-            f.create( true, true, null );
+            f.create(true, true, null);
         }
 
-        return projectPath.append( src );
+        return projectPath.append(src);
     }
 
-
-    final void doRemoveProject( IProgressMonitor monitor ) throws CoreException
+    final void doRemoveProject(IProgressMonitor monitor) throws CoreException
     {
-        final boolean noProgressMonitor = ( currentProjectLocation == null ); // inside workspace
+        final boolean noProgressMonitor = (currentProjectLocation == null); // inside workspace
 
-        if ( monitor == null || noProgressMonitor )
+        if (monitor == null || noProgressMonitor)
         {
             monitor = new NullProgressMonitor();
         }
-        monitor.beginTask( "Remove project", 3 );
+        monitor.beginTask("Remove project", 3);
         try
         {
             try
             {
-                boolean removeContent = currentProject.isSynchronized( IResource.DEPTH_INFINITE );
-                currentProject.delete( removeContent, false, new SubProgressMonitor( monitor, 2 ) );
+                boolean removeContent = currentProject.isSynchronized(IResource.DEPTH_INFINITE);
+                currentProject.delete(removeContent, false, new SubProgressMonitor(
+                    monitor, 2));
 
             }
             finally
@@ -240,19 +233,18 @@
         }
     }
 
-
-    private IClasspathEntry[] getProjectClassPath( IPath src ) throws CoreException
+    private IClasspathEntry[] getProjectClassPath(IPath src) throws CoreException
     {
         List<IClasspathEntry> cpEntries = new ArrayList<IClasspathEntry>();
-        cpEntries.add( JavaCore.newSourceEntry( src ) );
-        cpEntries.addAll( Arrays.asList( getDefaultClasspathEntry() ) );
-        cpEntries.add( JavaCore.newContainerEntry( new Path( SigilCore.CLASSPATH_CONTAINER_PATH ) ) );
-        IClasspathEntry[] entries = cpEntries.toArray( new IClasspathEntry[cpEntries.size()] );
+        cpEntries.add(JavaCore.newSourceEntry(src));
+        cpEntries.addAll(Arrays.asList(getDefaultClasspathEntry()));
+        cpEntries.add(JavaCore.newContainerEntry(new Path(
+            SigilCore.CLASSPATH_CONTAINER_PATH)));
+        IClasspathEntry[] entries = cpEntries.toArray(new IClasspathEntry[cpEntries.size()]);
 
         return entries;
     }
 
-
     private IClasspathEntry[] getDefaultClasspathEntry()
     {
         IClasspathEntry[] defaultJRELibrary = PreferenceConstants.getDefaultJRELibrary();
@@ -270,47 +262,45 @@
         return defaultJRELibrary;
     }
 
-
-    private void configureSigilProject( IProject project, String description, Version projectVersion,
-        String vendorName, String bundleName, IPath src, IProgressMonitor monitor ) throws CoreException
+    private void configureSigilProject(IProject project, String description,
+        Version projectVersion, String vendorName, String bundleName, IPath src,
+        IProgressMonitor monitor) throws CoreException
     {
-        ISigilProjectModel sigil = SigilCore.create( project );
-        IClasspathEntry cp = JavaCore.newSourceEntry( src );
-        String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry( cp );
+        ISigilProjectModel sigil = SigilCore.create(project);
+        IClasspathEntry cp = JavaCore.newSourceEntry(src);
+        String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry(cp);
 
         ISigilBundle bundle = sigil.getBundle();
-        bundle.addClasspathEntry( encodedClasspath );
+        bundle.addClasspathEntry(encodedClasspath);
 
-        if ( description != null )
+        if (description != null)
         {
-            bundle.getBundleInfo().setDescription( description );
+            bundle.getBundleInfo().setDescription(description);
         }
-        if ( projectVersion != null )
+        if (projectVersion != null)
         {
-            bundle.setVersion( projectVersion );
+            bundle.setVersion(projectVersion);
         }
-        if ( vendorName != null )
+        if (vendorName != null)
         {
-            bundle.getBundleInfo().setVendor( vendorName );
+            bundle.getBundleInfo().setVendor(vendorName);
         }
-        if ( bundleName != null )
+        if (bundleName != null)
         {
-            bundle.getBundleInfo().setName( bundleName );
+            bundle.getBundleInfo().setName(bundleName);
         }
-        sigil.save( monitor );
+        sigil.save(monitor);
     }
 
-
     private URI getProjectLocationURI() throws CoreException
     {
-        if ( firstPage.isInWorkspace() )
+        if (firstPage.isInWorkspace())
         {
             return null;
         }
         return firstPage.getLocationURI();
     }
 
-
     @Override
     public boolean isPageComplete()
     {
@@ -318,10 +308,9 @@
         return result;
     }
 
-
     protected void performCancel()
     {
-        if ( currentProject != null )
+        if (currentProject != null)
         {
             removeProject();
         }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizard.java
index 9b06878..eeda6b5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizard.java
@@ -19,40 +19,35 @@
 
 package org.apache.felix.sigil.eclipse.ui.wizard.repository;
 
-
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
 import org.eclipse.jface.wizard.IWizardPage;
 import org.eclipse.jface.wizard.Wizard;
 
-
 public class RepositoryWizard extends Wizard
 {
 
     private IRepositoryModel model;
 
-
     @Override
     public boolean performFinish()
     {
-        for ( IWizardPage page : getPages() )
+        for (IWizardPage page : getPages())
         {
-            if ( page instanceof RepositoryWizardPage )
+            if (page instanceof RepositoryWizardPage)
             {
-                RepositoryWizardPage rwp = ( RepositoryWizardPage ) page;
+                RepositoryWizardPage rwp = (RepositoryWizardPage) page;
                 rwp.storeFields();
             }
         }
         return true;
     }
 
-
     public IRepositoryModel getModel()
     {
         return model;
     }
 
-
-    public void init( IRepositoryModel model )
+    public void init(IRepositoryModel model)
     {
         this.model = model;
     }
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
index 200d31c..0a89a61 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.eclipse.ui.wizard.repository;
 
-
 import java.util.ArrayList;
 
 import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
@@ -32,7 +31,6 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 
-
 public abstract class RepositoryWizardPage extends WizardPage
 {
 
@@ -40,93 +38,86 @@
     private ArrayList<FieldEditor> editors = new ArrayList<FieldEditor>();
     private RepositoryWizard wizard;
 
-
-    protected RepositoryWizardPage( String pageName, RepositoryWizard parent )
+    protected RepositoryWizardPage(String pageName, RepositoryWizard parent)
     {
-        super( pageName );
-        setTitle( pageName );
+        super(pageName);
+        setTitle(pageName);
         this.wizard = parent;
     }
 
-
     public abstract void createFieldEditors();
 
-
-    public void addField( FieldEditor editor )
+    public void addField(FieldEditor editor)
     {
-        editors.add( editor );
+        editors.add(editor);
     }
 
-
-    public void createControl( Composite parent )
+    public void createControl(Composite parent)
     {
-        Composite control = new Composite( parent, SWT.NONE );
-        setControl( control );
+        Composite control = new Composite(parent, SWT.NONE);
+        setControl(control);
 
-        if ( getModel().getType().isDynamic() )
+        if (getModel().getType().isDynamic())
         {
-            nameEditor = new StringFieldEditor( "name", "Name:", control );
-            nameEditor.setStringValue( getModel().getName() );
-            nameEditor.getTextControl( getFieldEditorParent() ).addModifyListener( new ModifyListener()
-            {
-                public void modifyText( ModifyEvent e )
+            nameEditor = new StringFieldEditor("name", "Name:", control);
+            nameEditor.setStringValue(getModel().getName());
+            nameEditor.getTextControl(getFieldEditorParent()).addModifyListener(
+                new ModifyListener()
                 {
-                    checkPageComplete();
-                }
-            } );
+                    public void modifyText(ModifyEvent e)
+                    {
+                        checkPageComplete();
+                    }
+                });
         }
 
         createFieldEditors();
 
         int cols = nameEditor == null ? 0 : nameEditor.getNumberOfControls();
-        for ( FieldEditor e : editors )
+        for (FieldEditor e : editors)
         {
-            cols = Math.max( cols, e.getNumberOfControls() );
+            cols = Math.max(cols, e.getNumberOfControls());
         }
 
-        control.setLayout( new GridLayout( cols, false ) );
+        control.setLayout(new GridLayout(cols, false));
 
-        if ( nameEditor != null )
+        if (nameEditor != null)
         {
-            nameEditor.fillIntoGrid( getFieldEditorParent(), cols );
+            nameEditor.fillIntoGrid(getFieldEditorParent(), cols);
         }
 
-        for ( FieldEditor e : editors )
+        for (FieldEditor e : editors)
         {
-            e.fillIntoGrid( getFieldEditorParent(), cols );
-            e.setPreferenceStore( getModel().getPreferences() );
+            e.fillIntoGrid(getFieldEditorParent(), cols);
+            e.setPreferenceStore(getModel().getPreferences());
             e.load();
         }
 
         checkPageComplete();
     }
 
-
     protected void checkPageComplete()
     {
-        if ( nameEditor != null )
+        if (nameEditor != null)
         {
-            setPageComplete( nameEditor.getStringValue().length() > 0 );
+            setPageComplete(nameEditor.getStringValue().length() > 0);
         }
     }
 
-
     public IRepositoryModel getModel()
     {
         return wizard.getModel();
     }
 
-
     protected Composite getFieldEditorParent()
     {
-        return ( Composite ) getControl();
+        return (Composite) getControl();
     }
 
-
     public void storeFields()
     {
-        getModel().setName( nameEditor.getStringValue() );
-        for ( FieldEditor e : editors )
+        getModel().setName(nameEditor.getStringValue());
+        for (FieldEditor e : editors)
         {
             e.store();
         }
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/GlobCompiler.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/GlobCompiler.java
index 4f47962..ff64cd1 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/GlobCompiler.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/GlobCompiler.java
@@ -19,44 +19,42 @@
 
 package org.apache.felix.sigil.utils;
 
-
 import java.util.regex.Pattern;
 
-
 public class GlobCompiler
 {
-    public static final Pattern compile( String glob )
+    public static final Pattern compile(String glob)
     {
         char[] chars = glob.toCharArray();
-        if ( chars.length > 0 )
+        if (chars.length > 0)
         {
-            StringBuilder builder = new StringBuilder( chars.length + 5 );
+            StringBuilder builder = new StringBuilder(chars.length + 5);
 
-            builder.append( '^' );
+            builder.append('^');
 
-            for ( char c : chars )
+            for (char c : chars)
             {
-                switch ( c )
+                switch (c)
                 {
                     case '*':
-                        builder.append( ".*" );
+                        builder.append(".*");
                         break;
                     case '.':
-                        builder.append( "\\." );
+                        builder.append("\\.");
                         break;
                     case '$':
-                        builder.append( "\\$" );
+                        builder.append("\\$");
                         break;
                     default:
-                        builder.append( c );
+                        builder.append(c);
                 }
             }
 
-            return Pattern.compile( builder.toString() );
+            return Pattern.compile(builder.toString());
         }
         else
         {
-            return Pattern.compile( glob );
+            return Pattern.compile(glob);
         }
     }
 }
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/PathHelper.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/PathHelper.java
index f40929d..2cb2772 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/PathHelper.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/PathHelper.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.utils;
 
-
 import java.io.File;
 import java.util.List;
 import java.util.regex.Pattern;
@@ -27,23 +26,23 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 
-
 public class PathHelper
 {
 
-    public static void scanFiles( List<IPath> paths, IPath path, String pattern, boolean recurse )
+    public static void scanFiles(List<IPath> paths, IPath path, String pattern,
+        boolean recurse)
     {
-        Pattern p = GlobCompiler.compile( pattern );
+        Pattern p = GlobCompiler.compile(pattern);
 
-        for ( File f : path.toFile().listFiles() )
+        for (File f : path.toFile().listFiles())
         {
-            if ( f.isDirectory() && recurse )
+            if (f.isDirectory() && recurse)
             {
-                scanFiles( paths, new Path( f.getAbsolutePath() ), pattern, recurse );
+                scanFiles(paths, new Path(f.getAbsolutePath()), pattern, recurse);
             }
-            else if ( f.isFile() && p.matcher( f.getName() ).matches() )
+            else if (f.isFile() && p.matcher(f.getName()).matches())
             {
-                paths.add( new Path( f.getAbsolutePath() ) );
+                paths.add(new Path(f.getAbsolutePath()));
             }
         }
     }
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/SigilUtils.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/SigilUtils.java
index 51524e1..480d102 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/SigilUtils.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/SigilUtils.java
@@ -19,25 +19,23 @@
 
 package org.apache.felix.sigil.utils;
 
-
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.content.IContentType;
 
-
 public final class SigilUtils
 {
     private SigilUtils()
     {
     }
 
-
-    public static boolean isResourceType( IResource resource, String type )
+    public static boolean isResourceType(IResource resource, String type)
     {
-        IContentType[] types = Platform.getContentTypeManager().findContentTypesFor( resource.getName() );
-        for ( IContentType contentType : types )
+        IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(
+            resource.getName());
+        for (IContentType contentType : types)
         {
-            if ( contentType.getId().equals( type ) )
+            if (contentType.getId().equals(type))
             {
                 return true;
             }
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/EditorPropertyTester.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/EditorPropertyTester.java
index a94f511..647a317 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/EditorPropertyTester.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/EditorPropertyTester.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.utils.properties;
 
-
 import org.apache.felix.sigil.utils.SigilUtils;
 import org.eclipse.core.expressions.PropertyTester;
 import org.eclipse.core.resources.IFile;
@@ -28,26 +27,26 @@
 import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.IWorkbenchPart;
 
-
 public class EditorPropertyTester extends PropertyTester
 {
 
-    public boolean test( Object receiver, String property, Object[] args, Object expectedValue )
+    public boolean test(Object receiver, String property, Object[] args,
+        Object expectedValue)
     {
-        IWorkbenchPart part = ( IWorkbenchPart ) receiver;
+        IWorkbenchPart part = (IWorkbenchPart) receiver;
 
         boolean result = false;
 
-        if ( part instanceof IEditorPart )
+        if (part instanceof IEditorPart)
         {
-            IEditorInput input = ( ( IEditorPart ) part ).getEditorInput();
-            if ( input instanceof IFileEditorInput )
+            IEditorInput input = ((IEditorPart) part).getEditorInput();
+            if (input instanceof IFileEditorInput)
             {
-                IFile file = ( ( IFileEditorInput ) input ).getFile();
+                IFile file = ((IFileEditorInput) input).getFile();
 
-                if ( "isEditorOfType".equals( property ) )
+                if ("isEditorOfType".equals(property))
                 {
-                    result = SigilUtils.isResourceType( file, ( String ) expectedValue );
+                    result = SigilUtils.isResourceType(file, (String) expectedValue);
                 }
             }
         }
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/PartKindPropertyTester.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/PartKindPropertyTester.java
index 92653b1..d48542b 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/PartKindPropertyTester.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/PartKindPropertyTester.java
@@ -19,28 +19,27 @@
 
 package org.apache.felix.sigil.utils.properties;
 
-
 import org.eclipse.core.expressions.PropertyTester;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPart;
 
-
 public class PartKindPropertyTester extends PropertyTester
 {
 
-    public boolean test( Object receiver, String property, Object[] args, Object expectedValue )
+    public boolean test(Object receiver, String property, Object[] args,
+        Object expectedValue)
     {
-        IWorkbenchPart part = ( IWorkbenchPart ) receiver;
+        IWorkbenchPart part = (IWorkbenchPart) receiver;
 
         Object value;
-        if ( "partKind".equals( property ) )
+        if ("partKind".equals(property))
         {
-            if ( part instanceof IEditorPart )
+            if (part instanceof IEditorPart)
             {
                 value = "editor";
             }
-            else if ( part instanceof IViewPart )
+            else if (part instanceof IViewPart)
             {
                 value = "view";
             }
@@ -49,7 +48,7 @@
                 value = null;
             }
         }
-        else if ( "partId".equals( property ) )
+        else if ("partId".equals(property))
         {
             value = part.getSite().getId();
         }
@@ -58,7 +57,7 @@
             value = null;
         }
 
-        return expectedValue.equals( value );
+        return expectedValue.equals(value);
     }
 
 }
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/ResourceTypePropertyTester.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/ResourceTypePropertyTester.java
index 3c35b5d..13c13f3 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/ResourceTypePropertyTester.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/ResourceTypePropertyTester.java
@@ -19,33 +19,33 @@
 
 package org.apache.felix.sigil.utils.properties;
 
-
 import org.eclipse.core.expressions.PropertyTester;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.content.IContentType;
 
-
 public class ResourceTypePropertyTester extends PropertyTester
 {
 
-    public boolean test( Object receiver, String property, Object[] args, Object expectedValue )
+    public boolean test(Object receiver, String property, Object[] args,
+        Object expectedValue)
     {
-        if ( !( receiver instanceof IResource ) )
+        if (!(receiver instanceof IResource))
         {
             return false;
         }
 
         boolean result = false;
 
-        IResource resource = ( IResource ) receiver;
-        if ( "isResourceOfType".equals( property ) )
+        IResource resource = (IResource) receiver;
+        if ("isResourceOfType".equals(property))
         {
-            IContentType[] types = Platform.getContentTypeManager().findContentTypesFor( resource.getName() );
+            IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(
+                resource.getName());
 
-            for ( IContentType type : types )
+            for (IContentType type : types)
             {
-                if ( type.getId().equals( expectedValue ) )
+                if (type.getId().equals(expectedValue))
                 {
                     result = true;
                     break;
diff --git a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/Activator.java b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/Activator.java
index c722374..cee4020 100644
--- a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/Activator.java
+++ b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/Activator.java
@@ -33,37 +33,40 @@
 public class Activator implements BundleActivator
 {
 
-    public void start( final BundleContext ctx ) throws Exception
+    public void start(final BundleContext ctx) throws Exception
     {
         final Hashtable props = new Hashtable();
         props.put(CommandProcessor.COMMAND_SCOPE, "sigil");
         props.put(CommandProcessor.COMMAND_FUNCTION, new String[] { "junit" });
-        
-        ServiceTracker tracker = new ServiceTracker(ctx, JUnitService.class.getName(), null) {
+
+        ServiceTracker tracker = new ServiceTracker(ctx, JUnitService.class.getName(),
+            null)
+        {
             private Map<ServiceReference, ServiceRegistration> regs;
 
             @Override
-            public Object addingService( ServiceReference reference )
+            public Object addingService(ServiceReference reference)
             {
-                JUnitService svc = ( JUnitService ) super.addingService( reference );
-                ServiceRegistration reg = ctx.registerService( SigilJunit.class.getName(), new SigilJunit(svc), props );
+                JUnitService svc = (JUnitService) super.addingService(reference);
+                ServiceRegistration reg = ctx.registerService(SigilJunit.class.getName(),
+                    new SigilJunit(svc), props);
                 regs.put(reference, reg);
                 return svc;
             }
 
             @Override
-            public void removedService( ServiceReference reference, Object service )
+            public void removedService(ServiceReference reference, Object service)
             {
-                ServiceRegistration reg = regs.remove( reference );
+                ServiceRegistration reg = regs.remove(reference);
                 reg.unregister();
-                super.removedService( reference, service );
+                super.removedService(reference, service);
             }
-            
+
         };
         tracker.open();
     }
 
-    public void stop( BundleContext ctx ) throws Exception
+    public void stop(BundleContext ctx) throws Exception
     {
     }
 
diff --git a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/PrintListener.java b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/PrintListener.java
index 9bcad4a..627dcda 100644
--- a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/PrintListener.java
+++ b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/PrintListener.java
@@ -22,30 +22,35 @@
 import junit.framework.Test;
 import junit.framework.TestListener;
 
-public class PrintListener implements TestListener {
+public class PrintListener implements TestListener
+{
 
-    public PrintListener() {
+    public PrintListener()
+    {
     }
 
-    public void startTest(Test test) {
-        System.out.println( "Start " + test );
+    public void startTest(Test test)
+    {
+        System.out.println("Start " + test);
         System.out.flush();
     }
 
-    public void endTest(Test test) {
-        System.out.println( "End " + test );
+    public void endTest(Test test)
+    {
+        System.out.println("End " + test);
         System.out.flush();
     }
 
-
-    public void addError(Test test, Throwable t) {
-        System.out.println( "Error " + test );
+    public void addError(Test test, Throwable t)
+    {
+        System.out.println("Error " + test);
         t.printStackTrace(System.out);
         System.out.flush();
     }
 
-    public void addFailure(Test test, AssertionFailedError error) {
-        System.out.println( "Failure " + test + ": " + error.getMessage() );
+    public void addFailure(Test test, AssertionFailedError error)
+    {
+        System.out.println("Failure " + test + ": " + error.getMessage());
         System.out.flush();
     }
 }
diff --git a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/SigilJunit.java b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/SigilJunit.java
index dd55e4a..f13839e 100644
--- a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/SigilJunit.java
+++ b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/SigilJunit.java
@@ -39,82 +39,99 @@
 public class SigilJunit
 {
     private static final Options OPTIONS;
-    
-    static {
+
+    static
+    {
         OPTIONS = new Options();
         OPTIONS.addOption("d", "dir", true, "Directory to write ant test results to");
-        OPTIONS.addOption("q", "quiet", false, "Run tests quietly, i.e. don't print steps to console" );
+        OPTIONS.addOption("q", "quiet", false,
+            "Run tests quietly, i.e. don't print steps to console");
     }
-    
+
     private final JUnitService service;
-    
-    public SigilJunit(JUnitService service) {
+
+    public SigilJunit(JUnitService service)
+    {
         this.service = service;
     }
 
-    public boolean junit(String[] args) throws IOException, ParseException {
+    public boolean junit(String[] args) throws IOException, ParseException
+    {
         Parser p = new GnuParser();
         CommandLine cmd = p.parse(OPTIONS, args);
         String[] cargs = cmd.getArgs();
-        if ( cargs.length == 0 ) {
-            for ( String t : service.getTests() ) {
-                System.out.println( "\t" + t );
+        if (cargs.length == 0)
+        {
+            for (String t : service.getTests())
+            {
+                System.out.println("\t" + t);
                 System.out.flush();
             }
             return true;
         }
-        else {
-            boolean quiet = cmd.hasOption( 'q' );
+        else
+        {
+            boolean quiet = cmd.hasOption('q');
             String d = cmd.getOptionValue('d');
             File dir = null;
-            if ( d != null ) {
+            if (d != null)
+            {
                 dir = new File(d);
                 dir.mkdirs();
-                System.out.println( "Writing results to " + dir.getAbsolutePath() );
+                System.out.println("Writing results to " + dir.getAbsolutePath());
                 System.out.flush();
             }
-            return runTests( cargs, quiet, dir );
+            return runTests(cargs, quiet, dir);
         }
     }
-    
-    private boolean runTests(String[] args, boolean quiet, File dir) throws IOException {
+
+    private boolean runTests(String[] args, boolean quiet, File dir) throws IOException
+    {
         int count = 0;
         int failures = 0;
         int errors = 0;
-        for ( String t : args ) {
-            TestSuite[] tests = findTests( t );
-            if ( tests.length == 0 ) {
-                System.err.println( "No tests found for " + t );
+        for (String t : args)
+        {
+            TestSuite[] tests = findTests(t);
+            if (tests.length == 0)
+            {
+                System.err.println("No tests found for " + t);
             }
-            else {
-                for ( TestSuite test : tests ) {
+            else
+            {
+                for (TestSuite test : tests)
+                {
                     TestResult result = new TestResult();
-                    if ( !quiet ) {
-                        result.addListener( new PrintListener());
+                    if (!quiet)
+                    {
+                        result.addListener(new PrintListener());
                     }
-                    
+
                     JUnitTest antTest = null;
                     FileOutputStream fout = null;
                     XMLJUnitResultFormatter formatter = null;
-                    
-                    if ( dir != null ) {
+
+                    if (dir != null)
+                    {
                         antTest = new JUnitTest(t, false, false, true);
-        
+
                         formatter = new XMLJUnitResultFormatter();
                         formatter.startTestSuite(antTest);
-        
+
                         String name = "TEST-" + test.getName() + ".xml";
-                        
-                        File f = new File( dir, name );
-                        fout = new FileOutputStream( f );
+
+                        File f = new File(dir, name);
+                        fout = new FileOutputStream(f);
                         formatter.setOutput(fout);
                         result.addListener(formatter);
                     }
-                    
+
                     test.run(result);
-                    
-                    if ( dir != null ) {
-                        antTest.setCounts(result.runCount(), result.failureCount(), result.errorCount());
+
+                    if (dir != null)
+                    {
+                        antTest.setCounts(result.runCount(), result.failureCount(),
+                            result.errorCount());
                         formatter.endTestSuite(antTest);
                         fout.flush();
                         fout.close();
@@ -125,57 +142,68 @@
                 }
             }
         }
-        
-        System.out.println( "Ran " + count + " tests. " + failures + " failures " + errors + " errors." );
+
+        System.out.println("Ran " + count + " tests. " + failures + " failures " + errors
+            + " errors.");
         System.out.flush();
-        
+
         return failures + errors == 0;
     }
 
-    private TestSuite[] findTests(String t) {
-        if ( t.contains("*" ) ) {
+    private TestSuite[] findTests(String t)
+    {
+        if (t.contains("*"))
+        {
             Pattern p = compile(t);
             LinkedList<TestSuite> tests = new LinkedList<TestSuite>();
-            for ( String n : service.getTests() ) {
-                if ( p.matcher(n).matches() ) {
-                    tests.add( service.createTest(n) );
+            for (String n : service.getTests())
+            {
+                if (p.matcher(n).matches())
+                {
+                    tests.add(service.createTest(n));
                 }
             }
-            return tests.toArray( new TestSuite[tests.size()] );
+            return tests.toArray(new TestSuite[tests.size()]);
         }
-        else {
+        else
+        {
             TestSuite test = service.createTest(t);
             return test == null ? new TestSuite[0] : new TestSuite[] { test };
         }
     }
 
-    public static final Pattern compile(String glob) {
+    public static final Pattern compile(String glob)
+    {
         char[] chars = glob.toCharArray();
-        if ( chars.length > 0 ) {
+        if (chars.length > 0)
+        {
             StringBuilder builder = new StringBuilder(chars.length + 5);
-    
+
             builder.append('^');
-            
-            for (char c : chars) {
-                switch ( c ) {
-                case '*':
-                    builder.append(".*");
-                    break;
-                case '.':
-                    builder.append("\\.");
-                    break;
-                case '$':
-                    builder.append( "\\$" );
-                    break;
-                default:
-                    builder.append( c );
+
+            for (char c : chars)
+            {
+                switch (c)
+                {
+                    case '*':
+                        builder.append(".*");
+                        break;
+                    case '.':
+                        builder.append("\\.");
+                        break;
+                    case '$':
+                        builder.append("\\$");
+                        break;
+                    default:
+                        builder.append(c);
                 }
             }
-    
+
             return Pattern.compile(builder.toString());
         }
-        else {
+        else
+        {
             return Pattern.compile(glob);
         }
-    }    
+    }
 }
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleInfoTask.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleInfoTask.java
index 9b53cee..ad5bbb4 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleInfoTask.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleInfoTask.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.ant;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.util.jar.JarFile;
@@ -28,7 +27,6 @@
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
 
-
 public class BundleInfoTask extends Task
 {
     private File bundle;
@@ -36,51 +34,52 @@
     private String property;
     private String defaultValue;
 
-
     @Override
     public void execute() throws BuildException
     {
-        if ( bundle == null )
-            throw new BuildException( "missing attribute: bundle" );
-        if ( header == null )
-            throw new BuildException( "missing attribute: header" );
+        if (bundle == null)
+            throw new BuildException("missing attribute: bundle");
+        if (header == null)
+            throw new BuildException("missing attribute: header");
 
         JarFile jar = null;
-        
+
         try
         {
-            jar = new JarFile( bundle, false );
+            jar = new JarFile(bundle, false);
             Manifest mf = jar.getManifest();
-            String value = mf.getMainAttributes().getValue( header );
-            if ( property == null )
+            String value = mf.getMainAttributes().getValue(header);
+            if (property == null)
             {
-                log( header + "=" + value );
+                log(header + "=" + value);
             }
             else
             {
-                if ( "Bundle-SymbolicName".equals( header ) && value != null )
+                if ("Bundle-SymbolicName".equals(header) && value != null)
                 {
                     // remove singleton flag
-                    int semi = value.indexOf( ';' );
-                    if ( semi > 0 )
-                        value = value.substring( 0, semi );
+                    int semi = value.indexOf(';');
+                    if (semi > 0)
+                        value = value.substring(0, semi);
                 }
-                if ( value == null )
+                if (value == null)
                 {
                     value = defaultValue;
                 }
-                if ( value != null )
+                if (value != null)
                 {
-                    getProject().setNewProperty( property, value );
+                    getProject().setNewProperty(property, value);
                 }
             }
         }
-        catch ( IOException e )
+        catch (IOException e)
         {
-            throw new BuildException( "Failed to access bundle", e );
+            throw new BuildException("Failed to access bundle", e);
         }
-        finally {
-            if ( jar != null ) {
+        finally
+        {
+            if (jar != null)
+            {
                 try
                 {
                     jar.close();
@@ -94,26 +93,22 @@
         }
     }
 
-
-    public void setBundle( String bundle )
+    public void setBundle(String bundle)
     {
-        this.bundle = new File( bundle );
+        this.bundle = new File(bundle);
     }
 
-
-    public void setHeader( String header )
+    public void setHeader(String header)
     {
         this.header = header;
     }
 
-
-    public void setProperty( String property )
+    public void setProperty(String property)
     {
         this.property = property;
     }
 
-
-    public void setDefaultValue( String defaultValue )
+    public void setDefaultValue(String defaultValue)
     {
         this.defaultValue = defaultValue;
     }
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleTask.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleTask.java
index 712f372..ab2c4c2 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleTask.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleTask.java
@@ -130,7 +130,7 @@
                 log(id + ": " + count(nErr, "error") + ", " + count(nWarn, "warning")
                     + msg);
             }
-        
+
             if (revision != null)
             {
                 // FIXME: hopefully if we have multiple bundles they all have the same version
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
index 9670dcd..28d3e36 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
@@ -60,7 +60,7 @@
             {
                 continue;
             }
-            
+
             String optStr = repo.getProperty("optional", "false");
             boolean optional = Boolean.parseBoolean(optStr.trim());
 
@@ -98,7 +98,8 @@
             }
 
             int level = Integer.parseInt(repo.getProperty(
-                IRepositoryConfig.REPOSITORY_LEVEL, Integer.toString(IBundleRepository.NORMAL_PRIORITY)));
+                IRepositoryConfig.REPOSITORY_LEVEL,
+                Integer.toString(IBundleRepository.NORMAL_PRIORITY)));
 
             try
             {
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java
index 48ddd12d..1e33b66 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.ivy;
 
-
 import java.util.Map;
 import java.util.Properties;
 
@@ -31,7 +30,6 @@
 import org.apache.felix.sigil.common.repository.ResolutionConfig;
 import org.apache.felix.sigil.common.repository.ResolutionException;
 
-
 public class BldResolver implements IBldResolver
 {
     private Map<String, Properties> repos;
@@ -43,75 +41,72 @@
         {
             BldCore.init();
         }
-        catch ( Exception e )
+        catch (Exception e)
         {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
     };
 
-
-    public BldResolver( Map<String, Properties> repos )
+    public BldResolver(Map<String, Properties> repos)
     {
         this.repos = repos;
     }
 
-
-    public IResolution resolve( IModelElement element, boolean transitive )
+    public IResolution resolve(IModelElement element, boolean transitive)
     {
         int options = ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INCLUDE_OPTIONAL;
-        if ( transitive )
+        if (transitive)
             options |= ResolutionConfig.INCLUDE_DEPENDENTS;
 
-        ResolutionConfig config = new ResolutionConfig( options );
+        ResolutionConfig config = new ResolutionConfig(options);
         try
         {
-            return resolve( element, config );
+            return resolve(element, config);
         }
-        catch ( ResolutionException e )
+        catch (ResolutionException e)
         {
-            throw new IllegalStateException( "eek! this shouldn't happen when ignoreErrors=true", e );
+            throw new IllegalStateException(
+                "eek! this shouldn't happen when ignoreErrors=true", e);
         }
     }
 
-
-    public IResolution resolveOrFail( IModelElement element, boolean transitive ) throws ResolutionException
+    public IResolution resolveOrFail(IModelElement element, boolean transitive)
+        throws ResolutionException
     {
         int options = 0;
-        if ( transitive )
+        if (transitive)
             options |= ResolutionConfig.INCLUDE_DEPENDENTS;
-        ResolutionConfig config = new ResolutionConfig( options );
-        return resolve( element, config );
+        ResolutionConfig config = new ResolutionConfig(options);
+        return resolve(element, config);
     }
 
-
-    private IResolution resolve( IModelElement element, ResolutionConfig config ) throws ResolutionException
+    private IResolution resolve(IModelElement element, ResolutionConfig config)
+        throws ResolutionException
     {
-        if ( manager == null )
+        if (manager == null)
         {
-            manager = new BldRepositoryManager( repos );
+            manager = new BldRepositoryManager(repos);
         }
 
         IResolutionMonitor ivyMonitor = new IResolutionMonitor()
         {
-            public void endResolution( IModelElement requirement, ISigilBundle sigilBundle )
+            public void endResolution(IModelElement requirement, ISigilBundle sigilBundle)
             {
-                Log.debug( "Resolved " + requirement + " -> " + sigilBundle );
+                Log.debug("Resolved " + requirement + " -> " + sigilBundle);
             }
 
-
             public boolean isCanceled()
             {
                 return false;
             }
 
-
-            public void startResolution( IModelElement requirement )
+            public void startResolution(IModelElement requirement)
             {
-                Log.verbose( "Resolving " + requirement );
+                Log.verbose("Resolving " + requirement);
             }
         };
 
-        return manager.getBundleResolver().resolve( element, config, ivyMonitor );
+        return manager.getBundleResolver().resolve(element, config, ivyMonitor);
     }
 }
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java
index 911a8c8..2a6c7cd 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java
@@ -29,9 +29,10 @@
 {
     static final String WILD_ANY = "[^.]?.*";
     static final String WILD_ONE = "[^.]?[^;]*"; // WILD_ONE.endsWith(WILD_ANY) == false
-    
+
     // example pattern: ${repository}/projects/abc*/*/project.sigil
-    public static Collection<File> findFiles(File workingDir, String pattern) throws IOException
+    public static Collection<File> findFiles(File workingDir, String pattern)
+        throws IOException
     {
         int star = pattern.indexOf("*");
         if (star == -1)
@@ -49,7 +50,8 @@
         String[] patterns = regex.split("/");
 
         TreeSet<File> list = new TreeSet<File>();
-        File root = slash == -1 ? workingDir : new File(pattern.substring(0, slash)).getAbsoluteFile();
+        File root = slash == -1 ? workingDir
+            : new File(pattern.substring(0, slash)).getAbsoluteFile();
 
         if (root.isDirectory())
         {
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/IBldResolver.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/IBldResolver.java
index e338349..f39693d 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/IBldResolver.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/IBldResolver.java
@@ -19,16 +19,14 @@
 
 package org.apache.felix.sigil.ivy;
 
-
 import org.apache.felix.sigil.common.model.IModelElement;
 import org.apache.felix.sigil.common.repository.IResolution;
 import org.apache.felix.sigil.common.repository.ResolutionException;
 
-
 public interface IBldResolver
 {
-    IResolution resolveOrFail( IModelElement element, boolean transitive ) throws ResolutionException;
+    IResolution resolveOrFail(IModelElement element, boolean transitive)
+        throws ResolutionException;
 
-
-    IResolution resolve( IModelElement element, boolean transitive );
+    IResolution resolve(IModelElement element, boolean transitive);
 }
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/Log.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/Log.java
index 45171b5..7237ac2 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/Log.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/Log.java
@@ -19,10 +19,8 @@
 
 package org.apache.felix.sigil.ivy;
 
-
 import org.apache.ivy.util.Message;
 
-
 // ensure common prefix to all sigil messages
 public class Log
 {
@@ -30,45 +28,40 @@
 
     private static final boolean highlight = false;
 
-
-    public static void error( String msg )
+    public static void error(String msg)
     {
-        if ( highlight )
-            Message.deprecated( PREFIX + "[error] " + msg );
-        Message.error( PREFIX + msg );
+        if (highlight)
+            Message.deprecated(PREFIX + "[error] " + msg);
+        Message.error(PREFIX + msg);
     }
 
-
-    public static void warn( String msg )
+    public static void warn(String msg)
     {
-        if ( highlight )
-            Message.deprecated( PREFIX + "[warn] " + msg );
+        if (highlight)
+            Message.deprecated(PREFIX + "[warn] " + msg);
         else
-            Message.warn( PREFIX + msg );
+            Message.warn(PREFIX + msg);
     }
 
-
-    public static void info( String msg )
+    public static void info(String msg)
     {
-        if ( highlight )
-            Message.deprecated( PREFIX + "[info] " + msg );
+        if (highlight)
+            Message.deprecated(PREFIX + "[info] " + msg);
         else
-            Message.info( PREFIX + msg );
+            Message.info(PREFIX + msg);
     }
 
-
-    public static void verbose( String msg )
+    public static void verbose(String msg)
     {
-        Message.verbose( PREFIX + "[verbose] " + msg );
+        Message.verbose(PREFIX + "[verbose] " + msg);
     }
 
-
-    public static void debug( String msg )
+    public static void debug(String msg)
     {
-        if ( highlight )
-            Message.deprecated( PREFIX + "[debug] " + msg );
+        if (highlight)
+            Message.deprecated(PREFIX + "[debug] " + msg);
         else
-            Message.debug( PREFIX + msg );
+            Message.debug(PREFIX + msg);
     }
 
 }
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
index 703dabe..75a21fa 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
@@ -248,7 +248,8 @@
 
         for (IBldBundle bb : project.getBundles())
         {
-            IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(IBundleModelElement.class);
+            IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(
+                IBundleModelElement.class);
 
             for (IPackageExport pexport : bb.getExports())
             {
@@ -274,15 +275,18 @@
             Version version = VersionTable.getVersion(bb.getVersion());
             info.setVersion(version);
 
-            ISigilBundle pb = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
+            ISigilBundle pb = ModelElementFactory.getInstance().newModelElement(
+                ISigilBundle.class);
             pb.setBundleInfo(info);
-            
+
             Map<Object, Object> meta = new HashMap<Object, Object>();
             ModuleDescriptor md = SigilParser.instance().parseDescriptor(uri.toURL());
-            if ( !bb.getId().equals( md.getModuleRevisionId().getName() ) )
+            if (!bb.getId().equals(md.getModuleRevisionId().getName()))
             { // non-default artifact
-                for ( Artifact a : md.getAllArtifacts() ) {
-                    if ( a.getName().equals( bb.getId() ) ) {
+                for (Artifact a : md.getAllArtifacts())
+                {
+                    if (a.getName().equals(bb.getId()))
+                    {
                         meta.put(Artifact.class, a);
                         break;
                     }
@@ -291,7 +295,7 @@
 
             meta.put(ModuleDescriptor.class, md);
             pb.setMeta(meta);
-            
+
             list.add(pb);
             Log.debug("ProjectRepository: added " + pb);
             Log.debug("ProjectRepository: exports " + bb.getExports());
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepositoryProvider.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepositoryProvider.java
index e081344..026d981 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepositoryProvider.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepositoryProvider.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.ivy;
 
-
 import java.util.HashMap;
 import java.util.Properties;
 
@@ -27,25 +26,24 @@
 import org.apache.felix.sigil.common.repository.IRepositoryProvider;
 import org.apache.felix.sigil.common.repository.RepositoryException;
 
-
 public class ProjectRepositoryProvider implements IRepositoryProvider
 {
     private static HashMap<String, ProjectRepository> cache = new HashMap<String, ProjectRepository>();
 
-
-    public IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException
+    public IBundleRepository createRepository(String id, Properties properties)
+        throws RepositoryException
     {
-        ProjectRepository repository = cache.get( id );
+        ProjectRepository repository = cache.get(id);
 
-        if ( repository == null )
+        if (repository == null)
         {
-            String pattern = properties.getProperty( "pattern" );
-            if ( pattern == null )
+            String pattern = properties.getProperty("pattern");
+            if (pattern == null)
             {
-                throw new RepositoryException( "property 'pattern' not specified." );
+                throw new RepositoryException("property 'pattern' not specified.");
             }
-            repository = new ProjectRepository( id, pattern );
-            cache.put( id, repository );
+            repository = new ProjectRepository(id, pattern);
+            cache.put(id, repository);
         }
 
         return repository;
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
index e7eb9fe..faf7b23 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.ivy;
 
-
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -61,111 +60,102 @@
 import org.apache.ivy.plugins.repository.url.URLResource;
 import org.apache.ivy.plugins.resolver.DependencyResolver;
 
-
 public class SigilParser implements ModuleDescriptorParser
 {
 
     private static DelegateParser instance;
 
-
     // used by ProjectRepository
     static synchronized DelegateParser instance()
     {
-        if ( instance == null )
-            throw new IllegalStateException( "SigilParser is not instantiated." );
-        
+        if (instance == null)
+            throw new IllegalStateException("SigilParser is not instantiated.");
+
         return instance;
     }
 
-
     public SigilParser()
     {
-        synchronized(SigilParser.class) {
-            if ( instance == null )
+        synchronized (SigilParser.class)
+        {
+            if (instance == null)
             {
                 instance = new DelegateParser();
             }
         }
     }
 
-
     /**
      * In IvyDE, IvyContext is not available, so we can't find the SigilResolver.
      * This allows us to construct one.
      * @deprecated temporary to support IvyDE
      */
-    public void setConfig( String config )
+    public void setConfig(String config)
     {
         instance.config = config;
     }
 
-
     /**
      * sets delegate parser.
      * If not set, we delegate to the default Ivy parser.
      * @param type name returned by desired parser's getType() method.
      */
-    public void setDelegateType( String type )
+    public void setDelegateType(String type)
     {
-        for ( ModuleDescriptorParser parser : ModuleDescriptorParserRegistry.getInstance().getParsers() )
+        for (ModuleDescriptorParser parser : ModuleDescriptorParserRegistry.getInstance().getParsers())
         {
-            if ( parser.getType().equals( type ) )
+            if (parser.getType().equals(type))
             {
                 instance.delegate = parser;
                 break;
             }
         }
 
-        if ( instance.delegate == null )
+        if (instance.delegate == null)
         {
-            throw new IllegalArgumentException( "Can't find parser delegateType=" + type );
+            throw new IllegalArgumentException("Can't find parser delegateType=" + type);
         }
     }
 
-
     /**
      * sets default file name the delegate parser accepts.
      * If not set, defaults to "ivy.xml".
      * @param name
      */
-    public void setDelegateFile( String name )
+    public void setDelegateFile(String name)
     {
         instance.ivyFile = name;
     }
 
-
     /**
      * sets the dependencies to keep from the delegate parser.
      * If not set, all existing dependencies are dropped.
      * @param regex pattern matching dependency names to keep.
      */
-    public void setKeepDependencies( String regex )
+    public void setKeepDependencies(String regex)
     {
-        instance.keepDependencyPattern = Pattern.compile( regex );
+        instance.keepDependencyPattern = Pattern.compile(regex);
     }
 
-
     /**
      * reduce level of info logging.
      * @param quiet
      */
-    public void setQuiet( String quiet )
+    public void setQuiet(String quiet)
     {
-        instance.quiet = Boolean.parseBoolean( quiet );
+        instance.quiet = Boolean.parseBoolean(quiet);
     }
 
-
     /**
      * sets the SigilResolver we use.
      * If not set, we use the first SigilResolver we find.
      * @param name
      */
-    public void setResolver( String name )
+    public void setResolver(String name)
     {
         instance.resolverName = name;
     }
 
-
     /**
      * adds override element: <override name="X" pattern="Y" replace="Z"/>. Overrides
      * Ivy variables using a pattern substitution on the resource directory path.
@@ -177,58 +167,53 @@
      * the ivy:buildlist task won't work without this workaround.
      */
     // e.g. <override name="ant.project.name" pattern=".*/([^/]+)/([^/]+)$" replace="$1-$2"/>
-    public void addConfiguredOverride( Map<String, String> var )
+    public void addConfiguredOverride(Map<String, String> var)
     {
-        final String name = var.get( "name" );
-        final String regex = var.get( "pattern" );
-        final String replace = var.get( "replace" );
+        final String name = var.get("name");
+        final String regex = var.get("pattern");
+        final String replace = var.get("replace");
 
-        if ( name == null || regex == null || replace == null )
-            throw new IllegalArgumentException( "override must contain name, pattern and replace attributes." );
+        if (name == null || regex == null || replace == null)
+            throw new IllegalArgumentException(
+                "override must contain name, pattern and replace attributes.");
 
-        instance.varRegex.put( name, Pattern.compile( regex ) );
-        instance.varReplace.put( name, replace );
+        instance.varRegex.put(name, Pattern.compile(regex));
+        instance.varReplace.put(name, replace);
     }
 
-
     // implement ModuleDescriptorParser interface by delegation to singleton instance.
 
-    public boolean accept( Resource res )
+    public boolean accept(Resource res)
     {
-        return instance.accept( res );
+        return instance.accept(res);
     }
 
-
-    public Artifact getMetadataArtifact( ModuleRevisionId mrid, Resource res )
+    public Artifact getMetadataArtifact(ModuleRevisionId mrid, Resource res)
     {
-        return instance.getMetadataArtifact( mrid, res );
+        return instance.getMetadataArtifact(mrid, res);
     }
 
-
     public String getType()
     {
         return instance.getType();
     }
 
-
-    public ModuleDescriptor parseDescriptor( ParserSettings settings, URL xmlURL, boolean validate )
-        throws ParseException, IOException
+    public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL,
+        boolean validate) throws ParseException, IOException
     {
-        return instance.parseDescriptor( settings, xmlURL, validate );
+        return instance.parseDescriptor(settings, xmlURL, validate);
     }
 
-
-    public ModuleDescriptor parseDescriptor( ParserSettings settings, URL xmlURL, Resource res, boolean validate )
-        throws ParseException, IOException
+    public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL,
+        Resource res, boolean validate) throws ParseException, IOException
     {
-        return instance.parseDescriptor( settings, xmlURL, res, validate );
+        return instance.parseDescriptor(settings, xmlURL, res, validate);
     }
 
-
-    public void toIvyFile( InputStream source, Resource res, File destFile, ModuleDescriptor md )
-        throws ParseException, IOException
+    public void toIvyFile(InputStream source, Resource res, File destFile,
+        ModuleDescriptor md) throws ParseException, IOException
     {
-        instance.toIvyFile( source, res, destFile, md );
+        instance.toIvyFile(source, res, destFile, md);
     }
 
     /**
@@ -256,188 +241,187 @@
         private boolean quiet;
         private String config;
 
-
         @Override
-        public boolean accept( Resource res )
+        public boolean accept(Resource res)
         {
-            boolean accept = ( res instanceof SigilResolver.SigilIvy )
-                || res.getName().endsWith( "/" + SIGIL_BUILDLIST )
-                || ( ( instance.getSigilURI( res ) != null ) && ( ( instance.delegate != null ? instance.delegate
-                    .accept( res ) : false ) || super.accept( res ) ) );
-            if ( accept )
-                Log.verbose( "accepted: " + res );
+            boolean accept = (res instanceof SigilResolver.SigilIvy)
+                || res.getName().endsWith("/" + SIGIL_BUILDLIST)
+                || ((instance.getSigilURI(res) != null) && ((instance.delegate != null ? instance.delegate.accept(res)
+                    : false) || super.accept(res)));
+            if (accept)
+                Log.verbose("accepted: " + res);
             return accept;
         }
 
-
         @Override
-        public void toIvyFile( InputStream source, Resource res, File destFile, ModuleDescriptor md )
-            throws ParseException, IOException
+        public void toIvyFile(InputStream source, Resource res, File destFile,
+            ModuleDescriptor md) throws ParseException, IOException
         {
-            Log.verbose( "writing resource: " + res + " toIvyFile: " + destFile );
+            Log.verbose("writing resource: " + res + " toIvyFile: " + destFile);
             // source allows us to keep layout and comments,
             // but this doesn't work if source is not ivy.xml.
             // So just write file directly from descriptor.
             try
             {
-                XmlModuleDescriptorWriter.write( md, destFile );
+                XmlModuleDescriptorWriter.write(md, destFile);
             }
             finally
             {
-                if ( source != null )
+                if (source != null)
                     source.close();
             }
         }
 
-
         @Override
-        public ModuleDescriptor parseDescriptor( ParserSettings settings, URL xmlURL, boolean validate )
-            throws ParseException, IOException
+        public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL,
+            boolean validate) throws ParseException, IOException
         {
-            return parseDescriptor( settings, xmlURL, new URLResource( xmlURL ), validate );
+            return parseDescriptor(settings, xmlURL, new URLResource(xmlURL), validate);
         }
 
-
         @Override
-        public ModuleDescriptor parseDescriptor( ParserSettings settings, URL xmlURL, Resource res, boolean validate )
-            throws ParseException, IOException
+        public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL,
+            Resource res, boolean validate) throws ParseException, IOException
         {
             String cacheKey = xmlURL.toString() + settings.hashCode();
-            DefaultModuleDescriptor dmd = augmentedCache.get( cacheKey );
+            DefaultModuleDescriptor dmd = augmentedCache.get(cacheKey);
 
-            if ( dmd == null )
+            if (dmd == null)
             {
-                dmd = rawCache.get( cacheKey );
-                if ( dmd == null )
+                dmd = rawCache.get(cacheKey);
+                if (dmd == null)
                 {
-                    dmd = delegateParse( settings, xmlURL, res, validate );
+                    dmd = delegateParse(settings, xmlURL, res, validate);
                 }
 
-                if ( !quiet )
-                    Log.info( "augmenting module=" + dmd.getModuleRevisionId().getName() + " ant.project.name="
-                        + settings.substitute( "${ant.project.name}" ) );
+                if (!quiet)
+                    Log.info("augmenting module=" + dmd.getModuleRevisionId().getName()
+                        + " ant.project.name="
+                        + settings.substitute("${ant.project.name}"));
 
-                addDependenciesToDescriptor( res, dmd );
-                augmentedCache.put( cacheKey, dmd );
+                addDependenciesToDescriptor(res, dmd);
+                augmentedCache.put(cacheKey, dmd);
 
-                Log.verbose( "augmented dependencies: " + Arrays.asList( dmd.getDependencies() ) );
+                Log.verbose("augmented dependencies: "
+                    + Arrays.asList(dmd.getDependencies()));
             }
 
             return dmd;
         }
 
-
         // used by ProjectRepository
-        ModuleDescriptor parseDescriptor( URL projectURL ) throws ParseException, IOException
+        ModuleDescriptor parseDescriptor(URL projectURL) throws ParseException,
+            IOException
         {
-            if ( defaultSettings == null )
+            if (defaultSettings == null)
             {
                 Ivy ivy = IvyContext.getContext().peekIvy();
-                if ( ivy == null )
-                    throw new IllegalStateException( "can't get default settings - no ivy context." );
+                if (ivy == null)
+                    throw new IllegalStateException(
+                        "can't get default settings - no ivy context.");
                 defaultSettings = ivy.getSettings();
             }
 
-            URL ivyURL = new URL( projectURL, ivyFile );
+            URL ivyURL = new URL(projectURL, ivyFile);
             String cacheKey = ivyURL.toString() + defaultSettings.hashCode();
-            DefaultModuleDescriptor dmd = rawCache.get( cacheKey );
+            DefaultModuleDescriptor dmd = rawCache.get(cacheKey);
 
-            if ( dmd == null )
+            if (dmd == null)
             {
-                URLResource res = new URLResource( ivyURL );
+                URLResource res = new URLResource(ivyURL);
                 // Note: this doesn't contain the augmented dependencies, which is OK,
                 // since the ProjectRepository only needs the id and status.
-                dmd = delegateParse( defaultSettings, ivyURL, res, false );
-                rawCache.put( cacheKey, dmd );
+                dmd = delegateParse(defaultSettings, ivyURL, res, false);
+                rawCache.put(cacheKey, dmd);
             }
 
             return dmd;
         }
 
-
-        private DefaultModuleDescriptor delegateParse( ParserSettings settings, URL xmlURL, Resource res,
-            boolean validate ) throws ParseException, IOException
+        private DefaultModuleDescriptor delegateParse(ParserSettings settings,
+            URL xmlURL, Resource res, boolean validate) throws ParseException,
+            IOException
         {
             String resName = res.getName();
 
-            if ( resName.endsWith( "/" + SIGIL_BUILDLIST ) )
+            if (resName.endsWith("/" + SIGIL_BUILDLIST))
             {
-                String name = resName.substring( 0, resName.length() - SIGIL_BUILDLIST.length() );
-                res = res.clone( name + ivyFile );
-                xmlURL = new URL( xmlURL, ivyFile );
+                String name = resName.substring(0, resName.length()
+                    - SIGIL_BUILDLIST.length());
+                res = res.clone(name + ivyFile);
+                xmlURL = new URL(xmlURL, ivyFile);
             }
 
-            if ( settings instanceof IvySettings )
+            if (settings instanceof IvySettings)
             {
-                IvySettings ivySettings = ( IvySettings ) settings;
-                String dir = new File( res.getName() ).getParent();
+                IvySettings ivySettings = (IvySettings) settings;
+                String dir = new File(res.getName()).getParent();
 
-                for ( String name : varRegex.keySet() )
+                for (String name : varRegex.keySet())
                 {
-                    Pattern regex = varRegex.get( name );
-                    String replace = varReplace.get( name );
+                    Pattern regex = varRegex.get(name);
+                    String replace = varReplace.get(name);
 
-                    String value = regex.matcher( dir ).replaceAll( replace );
+                    String value = regex.matcher(dir).replaceAll(replace);
 
-                    Log.debug( "overriding variable " + name + "=" + value );
-                    ivySettings.setVariable( name, value );
+                    Log.debug("overriding variable " + name + "=" + value);
+                    ivySettings.setVariable(name, value);
                 }
             }
 
             ModuleDescriptor md = null;
-            if ( delegate == null || !delegate.accept( res ) )
+            if (delegate == null || !delegate.accept(res))
             {
-                md = super.parseDescriptor( settings, xmlURL, res, validate );
+                md = super.parseDescriptor(settings, xmlURL, res, validate);
             }
             else
             {
-                md = delegate.parseDescriptor( settings, xmlURL, res, validate );
+                md = delegate.parseDescriptor(settings, xmlURL, res, validate);
             }
 
-            return mungeDescriptor( md, res );
+            return mungeDescriptor(md, res);
         }
 
-
         /**
          * clones descriptor and removes dependencies, as descriptor MUST have
          * 'this' as the parser given to its constructor.
          * Only dependency names matched by keepDependencyPattern are kept,
          * as we're going to add our own dependencies later.
          */
-        private DefaultModuleDescriptor mungeDescriptor( ModuleDescriptor md, Resource res )
+        private DefaultModuleDescriptor mungeDescriptor(ModuleDescriptor md, Resource res)
         {
 
-            if ( ( md instanceof DefaultModuleDescriptor ) && ( md.getParser() == this )
-                && ( KEEP_ALL.equals( keepDependencyPattern ) ) )
+            if ((md instanceof DefaultModuleDescriptor) && (md.getParser() == this)
+                && (KEEP_ALL.equals(keepDependencyPattern)))
             {
-                return ( DefaultModuleDescriptor ) md;
+                return (DefaultModuleDescriptor) md;
             }
 
-            DefaultModuleDescriptor dmd = new DefaultModuleDescriptor( this, res );
+            DefaultModuleDescriptor dmd = new DefaultModuleDescriptor(this, res);
 
-            dmd.setModuleRevisionId( md.getModuleRevisionId() );
-            dmd.setPublicationDate( md.getPublicationDate() );
+            dmd.setModuleRevisionId(md.getModuleRevisionId());
+            dmd.setPublicationDate(md.getPublicationDate());
 
-            for ( Configuration c : md.getConfigurations() )
+            for (Configuration c : md.getConfigurations())
             {
                 String conf = c.getName();
 
-                dmd.addConfiguration( c );
+                dmd.addConfiguration(c);
 
-                for ( Artifact a : md.getArtifacts( conf ) )
+                for (Artifact a : md.getArtifacts(conf))
                 {
-                    dmd.addArtifact( conf, a );
+                    dmd.addArtifact(conf, a);
                 }
             }
 
-            if ( keepDependencyPattern != null )
+            if (keepDependencyPattern != null)
             {
-                for ( DependencyDescriptor dependency : md.getDependencies() )
+                for (DependencyDescriptor dependency : md.getDependencies())
                 {
                     String name = dependency.getDependencyId().getName();
-                    if ( keepDependencyPattern.matcher( name ).matches() )
+                    if (keepDependencyPattern.matcher(name).matches())
                     {
-                        dmd.addDependency( dependency );
+                        dmd.addDependency(dependency);
                     }
                 }
             }
@@ -445,119 +429,123 @@
             return dmd;
         }
 
-
         /*
          * find URI to Sigil project file. This assumes that it is in the same
          * directory as the ivy file.
          */
-        private URI getSigilURI( Resource res )
+        private URI getSigilURI(Resource res)
         {
             URI uri = null;
 
-            if ( res instanceof URLResource )
+            if (res instanceof URLResource)
             {
-                URL url = ( ( URLResource ) res ).getURL();
-                uri = URI.create( url.toString() ).resolve( IBldProject.PROJECT_FILE );
+                URL url = ((URLResource) res).getURL();
+                uri = URI.create(url.toString()).resolve(IBldProject.PROJECT_FILE);
                 try
                 {
                     InputStream stream = uri.toURL().openStream(); // check file
                     // exists
                     stream.close();
                 }
-                catch ( IOException e )
+                catch (IOException e)
                 {
                     uri = null;
                 }
             }
-            else if ( res instanceof FileResource )
+            else if (res instanceof FileResource)
             {
-                uri = ( ( FileResource ) res ).getFile().toURI().resolve( IBldProject.PROJECT_FILE );
-                if ( !( new File( uri ).exists() ) )
+                uri = ((FileResource) res).getFile().toURI().resolve(
+                    IBldProject.PROJECT_FILE);
+                if (!(new File(uri).exists()))
                     uri = null;
             }
 
             return uri;
         }
 
-
         /*
          * add sigil dependencies to ModuleDescriptor.
          */
-        private void addDependenciesToDescriptor( Resource res, DefaultModuleDescriptor md ) throws IOException
+        private void addDependenciesToDescriptor(Resource res, DefaultModuleDescriptor md)
+            throws IOException
         {
             // FIXME: transitive should be configurable
             final boolean transitive = true; // ivy default is true
             final boolean changing = false;
             final boolean force = false;
 
-            URI uri = getSigilURI( res );
-            if ( uri == null )
+            URI uri = getSigilURI(res);
+            if (uri == null)
                 return;
 
             IBldProject project;
 
-            project = BldFactory.getProject( uri );
+            project = BldFactory.getProject(uri);
 
             IBundleModelElement requirements = project.getDependencies();
-            Log.verbose( "requirements: " + Arrays.asList( requirements.children() ) );
+            Log.verbose("requirements: " + Arrays.asList(requirements.children()));
 
             // preserve version range for Require-Bundle
             // XXX: synthesise bundle version range corresponding to package version ranges?
             HashMap<String, VersionRange> versions = new HashMap<String, VersionRange>();
-            for ( IModelElement child : requirements.children() )
+            for (IModelElement child : requirements.children())
             {
-                if ( child instanceof IRequiredBundle )
+                if (child instanceof IRequiredBundle)
                 {
-                    IRequiredBundle bundle = ( IRequiredBundle ) child;
-                    versions.put( bundle.getSymbolicName(), bundle.getVersions() );
+                    IRequiredBundle bundle = (IRequiredBundle) child;
+                    versions.put(bundle.getSymbolicName(), bundle.getVersions());
                 }
             }
 
             IBldResolver resolver = findResolver();
-            if ( resolver == null )
+            if (resolver == null)
             {
                 // this can happen in IvyDE, but it retries and is OK next time.
-                Log.warn( "failed to find resolver - IvyContext not yet available." );
+                Log.warn("failed to find resolver - IvyContext not yet available.");
                 return;
             }
 
-            IResolution resolution = resolver.resolve( requirements, false );
-            Log.verbose( "resolution: " + resolution.getBundles() );
+            IResolution resolution = resolver.resolve(requirements, false);
+            Log.verbose("resolution: " + resolution.getBundles());
 
             ModuleRevisionId masterMrid = md.getModuleRevisionId();
             DefaultDependencyDescriptor dd;
             ModuleRevisionId mrid;
 
-            for ( ISigilBundle bundle : resolution.getBundles() )
+            for (ISigilBundle bundle : resolution.getBundles())
             {
                 IBundleModelElement info = bundle.getBundleInfo();
                 String name = info.getSymbolicName();
 
-                if ( "system bundle".equals(name) )
+                if ("system bundle".equals(name))
                 {
                     // e.g. SystemProvider with framework=null
-                    Log.verbose( "Discarding system bundle" );
+                    Log.verbose("Discarding system bundle");
                     continue;
                 }
 
-                ModuleDescriptor bmd = (ModuleDescriptor) bundle.getMeta().get(ModuleDescriptor.class);
-                if ( bmd != null )
+                ModuleDescriptor bmd = (ModuleDescriptor) bundle.getMeta().get(
+                    ModuleDescriptor.class);
+                if (bmd != null)
                 {
                     ModuleRevisionId bmrid = bmd.getModuleRevisionId();
                     String org = bmrid.getOrganisation();
-                    if ( org == null )
+                    if (org == null)
                         org = masterMrid.getOrganisation();
                     String module = bmrid.getName();
                     String rev = "latest." + bmd.getStatus();
 
-                    mrid = ModuleRevisionId.newInstance( org, module, rev );
-                    
-                    dd = new SigilDependencyDescriptor( md, mrid, force, changing, transitive );
+                    mrid = ModuleRevisionId.newInstance(org, module, rev);
+
+                    dd = new SigilDependencyDescriptor(md, mrid, force, changing,
+                        transitive);
 
                     Artifact artifact = (Artifact) bundle.getMeta().get(Artifact.class);
-                    if ( artifact != null ) {
-                        dd.addDependencyArtifact( mrid.getName(), new DefaultDependencyArtifactDescriptor( dd, artifact.getName(), "jar",
-                            "jar", null, null ) );                        
+                    if (artifact != null)
+                    {
+                        dd.addDependencyArtifact(mrid.getName(),
+                            new DefaultDependencyArtifactDescriptor(dd,
+                                artifact.getName(), "jar", "jar", null, null));
                     }
                 }
                 else
@@ -568,133 +556,140 @@
                     // VersionRange version = versions.get( name );
                     // String rev = version != null ? version.toString() : info.getVersion().toString();
                     String rev = info.getVersion().toString();
-                    mrid = ModuleRevisionId.newInstance( SigilResolver.ORG_SIGIL, name, rev );
-                    dd = new SigilDependencyDescriptor( md, mrid, force, changing, transitive );
+                    mrid = ModuleRevisionId.newInstance(SigilResolver.ORG_SIGIL, name,
+                        rev);
+                    dd = new SigilDependencyDescriptor(md, mrid, force, changing,
+                        transitive);
                 }
 
                 int nDeps = 0;
                 boolean foundDefault = false;
 
                 // TODO: make dependency configurations configurable SIGIL-176
-                for ( String conf : md.getConfigurationsNames() )
+                for (String conf : md.getConfigurationsNames())
                 {
-                    if ( conf.equals( "default" ) )
+                    if (conf.equals("default"))
                     {
                         foundDefault = true;
                     }
-                    else if ( md.getArtifacts( conf ).length == 0 )
+                    else if (md.getArtifacts(conf).length == 0)
                     {
-                        dd.addDependencyConfiguration( conf, conf + "(default)" );
+                        dd.addDependencyConfiguration(conf, conf + "(default)");
                         nDeps++;
                     }
                 }
 
-                if ( nDeps > 0 )
+                if (nDeps > 0)
                 {
-                    if ( foundDefault )
-                        dd.addDependencyConfiguration( "default", "default" );
+                    if (foundDefault)
+                        dd.addDependencyConfiguration("default", "default");
                 }
                 else
                 {
-                    dd.addDependencyConfiguration( "*", "*" ); // all configurations
+                    dd.addDependencyConfiguration("*", "*"); // all configurations
                 }
 
-                md.addDependency( dd );
+                md.addDependency(dd);
             }
 
             boolean resolved = true;
-            for ( IModelElement child : requirements.children() )
+            for (IModelElement child : requirements.children())
             {
-                ISigilBundle provider = resolution.getProvider( child );
-                if ( provider == null )
+                ISigilBundle provider = resolution.getProvider(child);
+                if (provider == null)
                 {
                     resolved = false;
                     // this is parse phase, so only log verbose message.
                     // error is produced during resolution phase.
-                    Log.verbose( "WARN: can't resolve: " + child );
+                    Log.verbose("WARN: can't resolve: " + child);
 
                     String name;
                     String version;
-                    if ( child instanceof IRequiredBundle )
+                    if (child instanceof IRequiredBundle)
                     {
-                        IRequiredBundle rb = ( IRequiredBundle ) child;
+                        IRequiredBundle rb = (IRequiredBundle) child;
                         name = rb.getSymbolicName();
                         version = rb.getVersions().toString();
                     }
                     else
                     {
-                        IPackageImport pi = ( IPackageImport ) child;
+                        IPackageImport pi = (IPackageImport) child;
                         name = "import!" + pi.getPackageName();
                         version = pi.getVersions().toString();
                     }
 
-                    mrid = ModuleRevisionId.newInstance( "!" + SigilResolver.ORG_SIGIL, name, version );
-                    dd = new SigilDependencyDescriptor( md, mrid, force, changing, transitive );
-                    dd.addDependencyConfiguration( "*", "*" ); // all
+                    mrid = ModuleRevisionId.newInstance("!" + SigilResolver.ORG_SIGIL,
+                        name, version);
+                    dd = new SigilDependencyDescriptor(md, mrid, force, changing,
+                        transitive);
+                    dd.addDependencyConfiguration("*", "*"); // all
                     // configurations
-                    md.addDependency( dd );
+                    md.addDependency(dd);
                 }
             }
 
-            if ( !resolved )
+            if (!resolved)
             {
                 // Ivy does not show warnings or errors logged from parse phase, until after resolution.
                 // but <buildlist> ant task doesn't do resolution, so errors would be silently ignored.
                 // Hence, we must use Message.info to ensure this failure is seen.
-                if ( !quiet )
-                    Log.info( "WARN: resolution failed in: " + masterMrid.getName() + ". Use -v for details." );
+                if (!quiet)
+                    Log.info("WARN: resolution failed in: " + masterMrid.getName()
+                        + ". Use -v for details.");
             }
         }
 
-
         /*
          * find named resolver, or first resolver that implements IBldResolver.
          */
         private IBldResolver findResolver()
         {
-            if ( resolver == null )
+            if (resolver == null)
             {
                 Ivy ivy = IvyContext.getContext().peekIvy();
-                if ( ivy != null )
+                if (ivy != null)
                 {
-                    if ( resolverName != null )
+                    if (resolverName != null)
                     {
-                        DependencyResolver r = ivy.getSettings().getResolver( resolverName );
-                        if ( r == null )
+                        DependencyResolver r = ivy.getSettings().getResolver(resolverName);
+                        if (r == null)
                         {
-                            throw new Error( "SigilParser: resolver \"" + resolverName + "\" not defined." );
+                            throw new Error("SigilParser: resolver \"" + resolverName
+                                + "\" not defined.");
                         }
-                        else if ( r instanceof IBldResolver )
+                        else if (r instanceof IBldResolver)
                         {
-                            resolver = ( IBldResolver ) r;
+                            resolver = (IBldResolver) r;
                         }
                         else
                         {
-                            throw new Error( "SigilParser: resolver \"" + resolverName + "\" is not a SigilResolver." );
+                            throw new Error("SigilParser: resolver \"" + resolverName
+                                + "\" is not a SigilResolver.");
                         }
                     }
                     else
                     {
-                        for ( Object r : ivy.getSettings().getResolvers() )
+                        for (Object r : ivy.getSettings().getResolvers())
                         {
-                            if ( r instanceof IBldResolver )
+                            if (r instanceof IBldResolver)
                             {
-                                resolver = ( IBldResolver ) r;
+                                resolver = (IBldResolver) r;
                                 break;
                             }
                         }
                     }
 
-                    if ( resolver == null )
+                    if (resolver == null)
                     {
-                        throw new Error( "SigilParser: can't find SigilResolver. Check ivysettings.xml." );
+                        throw new Error(
+                            "SigilParser: can't find SigilResolver. Check ivysettings.xml.");
                     }
                 }
-                else if ( config != null )
+                else if (config != null)
                 {
-                    Log.warn( "creating duplicate resolver to support IvyDE." );
+                    Log.warn("creating duplicate resolver to support IvyDE.");
                     resolver = new SigilResolver();
-                    ( ( SigilResolver ) resolver ).setConfig( config );
+                    ((SigilResolver) resolver).setConfig(config);
                 }
             }
             return resolver;
@@ -709,9 +704,8 @@
  */
 class SigilDependencyDescriptor extends DefaultDependencyDescriptor
 {
-    public SigilDependencyDescriptor( DefaultModuleDescriptor md, ModuleRevisionId mrid, boolean force,
-        boolean changing, boolean transitive )
+    public SigilDependencyDescriptor(DefaultModuleDescriptor md, ModuleRevisionId mrid, boolean force, boolean changing, boolean transitive)
     {
-        super( md, mrid, force, changing, transitive );
+        super(md, mrid, force, changing, transitive);
     }
 }
\ No newline at end of file
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
index e1e243a..36cca28 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
@@ -19,7 +19,6 @@
 
 package org.apache.felix.sigil.ivy;
 
-
 import static java.lang.String.format;
 
 import java.io.File;
@@ -56,7 +55,6 @@
 import org.apache.ivy.plugins.resolver.util.ResolvedResource;
 import org.apache.ivy.util.FileUtil;
 
-
 /**
  * This resolver is able to work with Sigil repositories.
  * It does not allow publishing.
@@ -71,7 +69,6 @@
     private boolean extractBCP = false;
     private Map<String, Resource> resourcesCache = new HashMap<String, Resource>();
 
-
     /**
      * no-args constructor required by Ivy.
      * 
@@ -86,121 +83,115 @@
     {
     }
 
-
-    public void setConfig( String config )
+    public void setConfig(String config)
     {
         this.config = config;
     }
 
-
     /**
      * if true, resolver extracts any jars embedded in Bundle-ClassPath.
      */
-    public void setExtractBCP( String extract )
+    public void setExtractBCP(String extract)
     {
-        this.extractBCP = Boolean.parseBoolean( extract );
+        this.extractBCP = Boolean.parseBoolean(extract);
     }
 
-
     private IBldResolver getResolver()
     {
-        if ( resolver == null )
+        if (resolver == null)
         {
-            if ( config == null )
+            if (config == null)
             {
-                throw new Error( "SigilResolver: not configured. Specify config=\"PATH\" in ivysettings.xml." );
+                throw new Error(
+                    "SigilResolver: not configured. Specify config=\"PATH\" in ivysettings.xml.");
             }
             try
             {
                 URI uri;
-                File file = new File( config );
+                File file = new File(config);
 
-                if ( file.isAbsolute() )
+                if (file.isAbsolute())
                 {
                     uri = file.toURI();
                 }
                 else
                 {
-                    URI cwd = new File( "." ).toURI();
-                    uri = cwd.resolve( config );
+                    URI cwd = new File(".").toURI();
+                    uri = cwd.resolve(config);
                 }
 
-                Map<String, Properties> repositories = BldFactory.getConfig( uri ).getRepositoryConfig();
-                resolver = new BldResolver( repositories );
+                Map<String, Properties> repositories = BldFactory.getConfig(uri).getRepositoryConfig();
+                resolver = new BldResolver(repositories);
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
-                throw new Error( "SigilResolver: failed to configure: " + e );
+                throw new Error("SigilResolver: failed to configure: " + e);
             }
         }
         return resolver;
     }
 
-
-    public IResolution resolveOrFail( IModelElement element, boolean transitive ) throws ResolutionException
+    public IResolution resolveOrFail(IModelElement element, boolean transitive)
+        throws ResolutionException
     {
-        return getResolver().resolveOrFail( element, transitive );
+        return getResolver().resolveOrFail(element, transitive);
     }
 
-
-    public IResolution resolve( IModelElement element, boolean transitive )
+    public IResolution resolve(IModelElement element, boolean transitive)
     {
-        return getResolver().resolve( element, transitive );
+        return getResolver().resolve(element, transitive);
     }
 
-
     public String getTypeName()
     {
         return "sigil";
     }
 
-
     /*
      * synthesize an ivy descriptor for a Sigil dependency. called after Sigil
      * resolution, so descriptor already contains resolved version.
      */
-    public ResolvedResource findIvyFileRef( DependencyDescriptor dd, ResolveData data )
+    public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data)
     {
         ResolvedResource ref = null;
 
         ModuleRevisionId id = dd.getDependencyRevisionId();
 
-        if ( !id.getOrganisation().equals( ORG_SIGIL ) )
+        if (!id.getOrganisation().equals(ORG_SIGIL))
         {
             return null;
         }
 
-        ISigilBundle bundle = resolve( id );
-        if ( bundle == null )
+        ISigilBundle bundle = resolve(id);
+        if (bundle == null)
         {
-            Log.error( "Failed to find bundle for module " + id );
+            Log.error("Failed to find bundle for module " + id);
             return null;
         }
 
         String symbolicName = id.getName();
         String version = bundle.getVersion().toString();
 
-        Resource res = new SigilIvy( extractBCP ? bundle : null, symbolicName, version );
-        ref = new ResolvedResource( res, version );
+        Resource res = new SigilIvy(extractBCP ? bundle : null, symbolicName, version);
+        ref = new ResolvedResource(res, version);
 
-        Log.debug( format( "findIvyFileRef: dd=%s => ref=%s", dd, ref ) );
+        Log.debug(format("findIvyFileRef: dd=%s => ref=%s", dd, ref));
         return ref;
     }
 
-
     @Override
-    protected ResolvedResource findArtifactRef( Artifact artifact, Date date )
+    protected ResolvedResource findArtifactRef(Artifact artifact, Date date)
     {
         String name = artifact.getName();
         ModuleRevisionId id = artifact.getModuleRevisionId();
 
-        if ( !id.getOrganisation().equals( ORG_SIGIL ) )
+        if (!id.getOrganisation().equals(ORG_SIGIL))
         {
             return null;
         }
 
-        ISigilBundle bundle = resolve( id );
-        if ( bundle == null )
+        ISigilBundle bundle = resolve(id);
+        if (bundle == null)
         {
             return null;
         }
@@ -211,33 +202,33 @@
 
         try
         {
-            URL url = ( uri != null ) ? uri.toURL() : bundle.getLocation().toURL();
-            if ( name.contains( "!" ) )
+            URL url = (uri != null) ? uri.toURL() : bundle.getLocation().toURL();
+            if (name.contains("!"))
             {
-                String[] split = name.split( "!" );
-                url = new URL( "jar:" + url + "!/" + split[1] + "." + artifact.getExt() );
+                String[] split = name.split("!");
+                url = new URL("jar:" + url + "!/" + split[1] + "." + artifact.getExt());
             }
-            res = new URLResource( url );
+            res = new URLResource(url);
         }
-        catch ( MalformedURLException e )
+        catch (MalformedURLException e)
         {
-            System.out.println( "Oops! " + e );
+            System.out.println("Oops! " + e);
         }
 
         String version = bundle.getVersion().toString();
-        ResolvedResource ref = new ResolvedResource( res, version );
+        ResolvedResource ref = new ResolvedResource(res, version);
 
-        Log.debug( format( "findArtifactRef: artifact=%s, date=%s => ref=%s", artifact, date, ref ) );
+        Log.debug(format("findArtifactRef: artifact=%s, date=%s => ref=%s", artifact,
+            date, ref));
         return ref;
     }
 
-
-    private ISigilBundle resolve( ModuleRevisionId id )
+    private ISigilBundle resolve(ModuleRevisionId id)
     {
         String revision = id.getRevision();
         String range = revision;
 
-        if ( revision.indexOf( ',' ) < 0 )
+        if (revision.indexOf(',') < 0)
         {
             // SigilParser has already resolved the revision from the import
             // version range.
@@ -247,83 +238,80 @@
             range = "[" + revision + "," + revision + "]";
         }
 
-        IRequiredBundle bundle = ModelElementFactory.getInstance().newModelElement(IRequiredBundle.class);
-        bundle.setSymbolicName( id.getName() );
-        bundle.setVersions( VersionRange.parseVersionRange( range ) );
+        IRequiredBundle bundle = ModelElementFactory.getInstance().newModelElement(
+            IRequiredBundle.class);
+        bundle.setSymbolicName(id.getName());
+        bundle.setVersions(VersionRange.parseVersionRange(range));
 
-        Log.verbose( "searching for " + bundle );
+        Log.verbose("searching for " + bundle);
 
         try
         {
-            IResolution resolution = resolveOrFail( bundle, false );
-            ISigilBundle[] bundles = resolution.getBundles().toArray( new ISigilBundle[0] );
-            if ( bundles.length == 1 )
+            IResolution resolution = resolveOrFail(bundle, false);
+            ISigilBundle[] bundles = resolution.getBundles().toArray(new ISigilBundle[0]);
+            if (bundles.length == 1)
             {
                 return bundles[0];
             }
         }
-        catch ( ResolutionException e )
+        catch (ResolutionException e)
         {
-            Log.warn( e.getMessage() );
+            Log.warn(e.getMessage());
             return null;
         }
         return null;
     }
 
-
     /*
      * Implement BasicResolver abstract methods
      */
 
     @Override
-    protected long get( Resource res, File dest ) throws IOException
+    protected long get(Resource res, File dest) throws IOException
     {
-        FileUtil.copy( res.openStream(), dest, null );
+        FileUtil.copy(res.openStream(), dest, null);
         long len = res.getContentLength();
-        Log.debug( format( "get(%s, %s) = %d", res, dest, len ) );
+        Log.debug(format("get(%s, %s) = %d", res, dest, len));
         return len;
     }
 
-
     @Override
-    public Resource getResource( String source ) throws IOException
+    public Resource getResource(String source) throws IOException
     {
-        source = encode( source );
-        Resource res = resourcesCache.get( source );
-        if ( res == null )
+        source = encode(source);
+        Resource res = resourcesCache.get(source);
+        if (res == null)
         {
-            res = new URLResource( new URL( source ) );
-            resourcesCache.put( source, res );
+            res = new URLResource(new URL(source));
+            resourcesCache.put(source, res);
         }
-        Log.debug( format( "SIGIL: getResource(%s) = %d", source, res ) );
+        Log.debug(format("SIGIL: getResource(%s) = %d", source, res));
         return res;
     }
 
-
-    private static String encode( String source )
+    private static String encode(String source)
     {
-        return source.trim().replaceAll( " ", "%20" );
+        return source.trim().replaceAll(" ", "%20");
     }
 
-
     @SuppressWarnings("unchecked")
     @Override
-    protected Collection findNames( Map tokenValues, String token )
+    protected Collection findNames(Map tokenValues, String token)
     {
-        throw new Error( "SigilResolver: findNames not supported." );
+        throw new Error("SigilResolver: findNames not supported.");
     }
 
-
-    public void publish( Artifact artifact, File src, boolean overwrite ) throws IOException
+    public void publish(Artifact artifact, File src, boolean overwrite)
+        throws IOException
     {
-        throw new Error( "SigilResolver: publish not supported." );
+        throw new Error("SigilResolver: publish not supported.");
     }
 
-
-    public void beginPublishTransaction( ModuleRevisionId module, boolean overwrite ) throws IOException
+    public void beginPublishTransaction(ModuleRevisionId module, boolean overwrite)
+        throws IOException
     {
         // stop publish attempts being silently ignored.
-        throw new Error( "SigilResolver: publish not supported." );
+        throw new Error("SigilResolver: publish not supported.");
     }
 
     /*
@@ -335,13 +323,11 @@
         private String name;
         private boolean exists = true;
 
-
         private SigilIvy()
         {
         }
 
-
-        public SigilIvy( ISigilBundle bundle, String module, String rev )
+        public SigilIvy(ISigilBundle bundle, String module, String rev)
         {
             this.name = "sigil!" + module + "#" + rev;
 
@@ -350,29 +336,29 @@
             String status = "release";
             String pub = "20080912162859";
 
-            content.append( "<ivy-module version=\"1.0\">\n" );
+            content.append("<ivy-module version=\"1.0\">\n");
 
-            content.append( format(
-                "<info organisation=\"%s\" module=\"%s\" revision=\"%s\" status=\"%s\" publication=\"%s\"/>\n", org,
-                module, rev, status, pub ) );
+            content.append(format(
+                "<info organisation=\"%s\" module=\"%s\" revision=\"%s\" status=\"%s\" publication=\"%s\"/>\n",
+                org, module, rev, status, pub));
 
-            String bcp = readBundleClassPath( bundle );
-            if ( bcp != null )
+            String bcp = readBundleClassPath(bundle);
+            if (bcp != null)
             {
-                content.append( "<publications>\n" );
-                for ( String j : bcp.split( ",\\s*" ) )
+                content.append("<publications>\n");
+                for (String j : bcp.split(",\\s*"))
                 {
-                    if ( j.equals( "." ) )
+                    if (j.equals("."))
                     {
-                        content.append( "<artifact/>\n" );
+                        content.append("<artifact/>\n");
                     }
-                    else if ( j.endsWith( ".jar" ) && bundleContains( bundle, j ) )
+                    else if (j.endsWith(".jar") && bundleContains(bundle, j))
                     {
-                        j = j.substring( 0, j.length() - 4 );
-                        content.append( format( "<artifact name=\"%s!%s\"/>\n", module, j ) );
+                        j = j.substring(0, j.length() - 4);
+                        content.append(format("<artifact name=\"%s!%s\"/>\n", module, j));
                     }
                 }
-                content.append( "</publications>\n" );
+                content.append("</publications>\n");
             }
 
             // TODO: add dependencies?
@@ -381,39 +367,38 @@
             // revConstraint="[1.2,1.3)"/>
             // </dependencies>
 
-            content.append( "</ivy-module>\n" );
+            content.append("</ivy-module>\n");
         }
 
-
-        private boolean bundleContains( ISigilBundle bundle, String j )
+        private boolean bundleContains(ISigilBundle bundle, String j)
         {
             InputStream is = null;
             try
             {
-                URL url = getURL( bundle );
+                URL url = getURL(bundle);
                 is = url.openStream();
-                JarInputStream js = new JarInputStream( is, false );
+                JarInputStream js = new JarInputStream(is, false);
                 JarEntry entry;
-                while ( ( entry = js.getNextJarEntry() ) != null )
+                while ((entry = js.getNextJarEntry()) != null)
                 {
-                    if ( j.equals( entry.getName() ) )
+                    if (j.equals(entry.getName()))
                     {
                         return true;
                     }
                 }
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
             }
             finally
             {
-                if ( is != null )
+                if (is != null)
                 {
                     try
                     {
                         is.close();
                     }
-                    catch ( IOException e2 )
+                    catch (IOException e2)
                     {
                     }
                 }
@@ -421,34 +406,33 @@
             return false;
         }
 
-
-        private String readBundleClassPath( ISigilBundle bundle )
+        private String readBundleClassPath(ISigilBundle bundle)
         {
-            if ( bundle == null )
+            if (bundle == null)
                 return null;
 
             InputStream is = null;
             try
             {
-                URL url = getURL( bundle );
+                URL url = getURL(bundle);
                 is = url.openStream();
-                JarInputStream js = new JarInputStream( is, false );
+                JarInputStream js = new JarInputStream(is, false);
                 Manifest m = js.getManifest();
-                if ( m != null )
-                    return ( String ) m.getMainAttributes().getValue( "Bundle-ClassPath" );
+                if (m != null)
+                    return (String) m.getMainAttributes().getValue("Bundle-ClassPath");
             }
-            catch ( IOException e )
+            catch (IOException e)
             {
             }
             finally
             {
-                if ( is != null )
+                if (is != null)
                 {
                     try
                     {
                         is.close();
                     }
-                    catch ( IOException e2 )
+                    catch (IOException e2)
                     {
                     }
                 }
@@ -457,77 +441,72 @@
             return null;
         }
 
-
-        private URL getURL( ISigilBundle bundle ) throws MalformedURLException
+        private URL getURL(ISigilBundle bundle) throws MalformedURLException
         {
             URI uri = bundle.getBundleInfo().getUpdateLocation();
-            if ( uri != null ) {
+            if (uri != null)
+            {
                 return uri.toURL();
             }
-            else {
+            else
+            {
                 File path = bundle.getLocation();
-                if ( path == null ) {
-                    throw new NullPointerException( "Missing location for " + bundle.getSymbolicName() );
+                if (path == null)
+                {
+                    throw new NullPointerException("Missing location for "
+                        + bundle.getSymbolicName());
                 }
                 return path.toURI().toURL();
             }
         }
 
-
         public String toString()
         {
             return "SigilIvy[" + name + "]";
         }
 
-
         // clone is used to read checksum files
         // so clone(getName() + ".sha1").exists() should be false
-        public Resource clone( String cloneName )
+        public Resource clone(String cloneName)
         {
-            Log.debug( "SigilIvy: clone: " + cloneName );
+            Log.debug("SigilIvy: clone: " + cloneName);
             SigilIvy clone = new SigilIvy();
             clone.name = cloneName;
             clone.exists = false;
             return clone;
         }
 
-
         public boolean exists()
         {
             return exists;
         }
 
-
         public long getContentLength()
         {
             return content.length();
         }
 
-
         public long getLastModified()
         {
             // TODO Auto-generated method stub
-            Log.debug( "NOT IMPLEMENTED: getLastModified" );
+            Log.debug("NOT IMPLEMENTED: getLastModified");
             return 0;
         }
 
-
         public String getName()
         {
             return name;
         }
 
-
         public boolean isLocal()
         {
             return false;
         }
 
-
         @SuppressWarnings("deprecation")
         public InputStream openStream() throws IOException
         {
-            return new java.io.StringBufferInputStream( content.toString() );
+            return new java.io.StringBufferInputStream(content.toString());
         }
     }
 }
