diff --git a/src/java/org/web3d/vrml/export/X3DRetainedSAXExporter.java b/src/java/org/web3d/vrml/export/X3DRetainedSAXExporter.java
index 430a0ae22391507419f1a388dce1c1b198e011c1..c6262b09095c8a7266abbb1f33cc2f5362430b06 100644
--- a/src/java/org/web3d/vrml/export/X3DRetainedSAXExporter.java
+++ b/src/java/org/web3d/vrml/export/X3DRetainedSAXExporter.java
@@ -39,8 +39,8 @@ import org.web3d.vrml.renderer.common.nodes.AbstractDynamicFieldNode;
 import org.web3d.vrml.sav.*;
 
 /**
- * A retained exporter that issues SAX events.  Extensions of this class
- * are expected to setup the content handler.  This class should contain
+ * A retained exporter that issues SAX events. Extensions of this class
+ * are expected to setup the content handler. This class should contain
  * as much of the XML specific knowledge as possible.
  *
  * This implementation will use FastInfoSet's AttributesHolder to
@@ -75,7 +75,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
     protected static final int DELTA_ZLIB_INT_ARRAY_ALGORITHM_ID = 33;
 
     /** An empty map to avoid null testing */
-    protected Map EMPTY_MAP = new HashMap();
+    protected Map EMPTY_MAP;
 
     /** The current indent level */
     protected int indent = 0;
@@ -188,6 +188,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         protoDeclSet = new HashSet<>();
         traverser = new SceneGraphTraverser();
         protoMap = new HashMap<>();
+        EMPTY_MAP = new HashMap();
 
         printDocType = false;
         printDocType = true;
@@ -397,8 +398,6 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
     protected void encodeFloatArray(float[] fval, int numElements, VRMLFieldDeclaration decl,
         String qName, AttributesHolder aholder, int ftype) {
 
-        int clen;
-
         if (fval != null && fval.length != 0) {
             String st = createX3DString(decl, fval, numElements);
 
@@ -422,8 +421,6 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
     protected void encodeDoubleArray(double[] fval, int numElements, VRMLFieldDeclaration decl,
         String qName, AttributesHolder aholder, int ftype) {
 
-        int clen;
-
         if (fval != null && fval.length != 0) {
             int span;
             int len2;
@@ -490,6 +487,9 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         Object proto;
         traverser.setObserver(this);
 
+        List<VRMLFieldDeclaration> fields;
+        Iterator<VRMLFieldDeclaration> itr2;
+        VRMLFieldDeclaration decl;
         while(itr.hasNext()) {
             proto = itr.next();
 
@@ -499,11 +499,11 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                 usedNodes.clear();
             } else {
                 printPrototypeDecl((PrototypeDecl)proto);
-                List<VRMLFieldDeclaration> fields = ((VRMLNodeTemplate)proto).getAllFields();
-                Iterator<VRMLFieldDeclaration> itr2 = fields.iterator();
+                fields = ((VRMLNodeTemplate)proto).getAllFields();
+                itr2 = fields.iterator();
 
                 while(itr2.hasNext()) {
-                    VRMLFieldDeclaration decl = itr2.next();
+                    decl = itr2.next();
 
                     if(decl == null)
                         continue;
@@ -612,8 +612,9 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         // Add user-specified attributes
         if (x3dAtts != null) {
             Iterator<Map.Entry<String,String>> itr = x3dAtts.entrySet().iterator();
+            Map.Entry<String,String> entry;
             while(itr.hasNext()) {
-                Map.Entry<String,String> entry = itr.next();
+                entry = itr.next();
                 atts.addAttribute(new QualifiedName("", "", entry.getKey()),
                     entry.getValue());
             }
@@ -640,9 +641,9 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
             handler.startElement("","head","head", new AttributesHolder());
             printNewLine();
 
-
+            AttributesHolder atts;
             for(int i=0; i < len; i++) {
-                AttributesHolder atts = new AttributesHolder();
+                atts = new AttributesHolder();
                 atts.addAttribute(new QualifiedName("", "", "name"),
                     comps[i].getName());
                 atts.addAttribute(new QualifiedName("", "", "level"),
@@ -665,9 +666,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
      */
     @Override
     public void printMetaData(Map<String, String> meta) {
-        Map.Entry[] entries;
-
-        entries = new Map.Entry[meta.size()];
+        Map.Entry[] entries = new Map.Entry[meta.size()];
         meta.entrySet().toArray(entries);
 
         int len = entries.length;
@@ -675,10 +674,11 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         indentUp();
 
         try {
+            AttributesHolder atts;
             for(int i=0; i < len; i++) {
                 printIndent();
 
-                AttributesHolder atts = new AttributesHolder();
+                atts = new AttributesHolder();
 
                 atts.addAttribute(new QualifiedName("", "", "name"),
                     (String)entries[i].getKey());
@@ -770,10 +770,11 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         String as;
 
         try {
+            AttributesHolder atts;
             for (Map.Entry<String, String> entrie : entries) {
                 name = entrie.getValue();
                 as = entrie.getKey();
-                AttributesHolder atts = new AttributesHolder();
+                atts = new AttributesHolder();
                 atts.addAttribute(new QualifiedName("", "", "localDEF"),
                         name);
                 if (as != null && !name.equals(as)) {
@@ -806,12 +807,13 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         Object obj;
         String[] defas;
         ImportNodeProxy proxy;
+        AttributesHolder atts;
 
         try {
             for (Map.Entry entrie : entries) {
                 exported = (String) entrie.getKey();
                 obj = entrie.getValue();
-                AttributesHolder atts = new AttributesHolder();
+                atts = new AttributesHolder();
                 if (obj instanceof String[]) {
                     defas = (String[]) entrie.getValue();
                     atts.addAttribute(new QualifiedName("", "","inlineDEF"),
@@ -981,14 +983,15 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         VRMLFieldData value;
         boolean printField;
         boolean printFieldDecl = false;
-        boolean printValue = false;
+        boolean printValue;
         int accessType;
         boolean hasChildren = false;
         int fieldMetadata = parent.getFieldIndex("metadata");
 
         printField = isProtoInstance;
-
         String fieldName;
+        VRMLFieldDeclaration decl;
+        AttributesHolder atts;
 
         for(int i = 0; i < fields.length; i++) {
             if (parent instanceof AbstractDynamicFieldNode) {
@@ -1044,7 +1047,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                 }
 
                 if (printField) {
-                    VRMLFieldDeclaration decl = parent.getFieldDeclaration(fields[i]);
+                    decl = parent.getFieldDeclaration(fields[i]);
                     printIndent();
 
                     try {
@@ -1066,8 +1069,8 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                         } else {
                             printIndent();
 
-                            AttributesHolder atts = new AttributesHolder();
-                                atts.addAttribute(new QualifiedName("", "", "name"),
+                            atts = new AttributesHolder();
+                            atts.addAttribute(new QualifiedName("", "", "name"),
                                     decl.getName());
 
                             handler.startElement("","fieldValue","fieldValue", atts);
@@ -1085,8 +1088,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                     }
                 } else {
                     // Check for containerfield
-                    VRMLFieldDeclaration decl =
-                        parent.getFieldDeclaration(fields[i]);
+                    decl = parent.getFieldDeclaration(fields[i]);
 
                     fieldName = decl.getName();
                 }
@@ -1139,7 +1141,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                     continue;
 
                 if (printField) {
-                    VRMLFieldDeclaration decl = parent.getFieldDeclaration(fields[i]);
+                    decl = parent.getFieldDeclaration(fields[i]);
                     printIndent();
 
                     try {
@@ -1160,7 +1162,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                                 continue;
                             }
                         } else {
-                            AttributesHolder atts = new AttributesHolder();
+                            atts = new AttributesHolder();
                             atts.addAttribute(new QualifiedName("", "",
                                 "name"), decl.getName());
 
@@ -1172,7 +1174,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                     }
                 } else {
                     // Check for containerfield
-                    VRMLFieldDeclaration decl = parent.getFieldDeclaration(fields[i]);
+                    decl = parent.getFieldDeclaration(fields[i]);
                     fieldName = decl.getName();
                 }
 
@@ -1223,20 +1225,22 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         int field_url = node.getFieldIndex("url");
         int field_metadata = node.getFieldIndex("metadata");
 
+        VRMLFieldDeclaration decl;
+        VRMLFieldData data;
+        StringBuilder buf = new StringBuilder("Can't get field: ");
+        int idx;
         // Handle all attributes first
         while(itr.hasNext()) {
-            VRMLFieldDeclaration decl = itr.next();
+            decl = itr.next();
 
             if(decl == null)
                 continue;
 
-            VRMLFieldData data;
-            int idx = node.getFieldIndex(decl.getName());
+            idx = node.getFieldIndex(decl.getName());
 
             try {
                 data = node.getFieldValue(idx);
             } catch(InvalidFieldException e) {
-                StringBuilder buf = new StringBuilder("Can't get field: ");
                 buf.append(decl.getName());
                 buf.append(" for: ");
                 buf.append(node);
@@ -1246,6 +1250,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                 buf.append(field_url);
 
                 errorReporter.errorReport(buf.toString(), null);
+                buf.setLength(0); // reset
                 continue;
             }
 
@@ -1279,18 +1284,16 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
 
         // Handle non-node <field> values
         while(itr.hasNext()) {
-            VRMLFieldDeclaration decl = itr.next();
+            decl = itr.next();
 
             if(decl == null)
                 continue;
 
-            VRMLFieldData data;
-            int idx = node.getFieldIndex(decl.getName());
+            idx = node.getFieldIndex(decl.getName());
 
             try {
                 data = node.getFieldValue(idx);
             } catch(InvalidFieldException e) {
-                StringBuilder buf = new StringBuilder("Can't get field: ");
                 buf.append(decl.getName());
                 buf.append(" for: ");
                 buf.append(node);
@@ -1300,6 +1303,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                 buf.append(field_url);
 
                 errorReporter.errorReport(buf.toString(), null);
+                buf.setLength(0); // reset
                 continue;
             }
 
@@ -1463,9 +1467,11 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         String fieldName;
 
         // Find IS relationships to pre-print
+        VRMLFieldDeclaration decl;
+        VRMLFieldDeclaration defaultDecl;
+        String is;
         while(itr.hasNext()) {
-            VRMLFieldDeclaration decl = itr.next();
-            VRMLFieldDeclaration defaultDecl = null;
+            decl = itr.next();
 
             if(decl == null)
                 continue;
@@ -1474,7 +1480,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
 
             idx = node.getFieldIndex(fieldName);
 
-            String is = findIS(node, idx, isMap);
+            is = findIS(node, idx, isMap);
 
             if (is != null) {
                 isList.add(new String[] {decl.getName(), is});
@@ -1490,9 +1496,13 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
 //            currentCompressor = new TestCompressor();
         }
 
+        VRMLFieldData data;
+        VRMLFieldData fdata;
+        String[] url;
+        int pos, midx, access;
+        String emd;
         while(itr.hasNext()) {
-            VRMLFieldDeclaration decl = itr.next();
-            VRMLFieldDeclaration defaultDecl = null;
+            decl = itr.next();
 
             if(decl == null)
                 continue;
@@ -1505,7 +1515,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                 defaultDecl = defaultNode.getFieldDeclaration(didx);
             }
 
-            String is = findIS(node, idx, isMap);
+            is = findIS(node, idx, isMap);
 
             if (is != null) {
                 continue;
@@ -1521,14 +1531,12 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                     continue;
             }
 
-            int access = decl.getAccessType();
+            access = decl.getAccessType();
             if (access == FieldConstants.EVENTIN || access == FieldConstants.EVENTOUT)
                 continue;
 
-            VRMLFieldData data;
             try {
                 data = node.getFieldValue(idx);
-
             } catch(InvalidFieldException e) {
                 // Don't print exceptions here.  There is a difference in spec setup
                 // between the default node and real one.  Not sure how best to deal with this.
@@ -1562,8 +1570,8 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                     continue;
             }
 
-            if (removeWorldUrl && (urlFields.contains(idx))) {
-                String[] url = data.stringArrayValues;
+            if (removeWorldUrl && urlFields.contains(idx)) {
+                url = data.stringArrayValues;
 
                 if (url != null && worldUrl != null) {
                     for(int j=0; j < url.length; j++) {
@@ -1578,11 +1586,11 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
 
             if (upgradeInline) {
                 if (decl.getName().equals("url")) {
-                    String[] url = data.stringArrayValues;
+                    url = data.stringArrayValues;
 
                     if (url != null) {
                         for(int j=0; j < url.length; j++) {
-                            int pos = url[j].indexOf(".wrl");
+                            pos = url[j].indexOf(".wrl");
                             if (pos >= 0) {
                                 url[j] = url[j].substring(0, pos);
                                 url[j] = url[j] + encodingTo;
@@ -1601,13 +1609,11 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
             atts.addAttribute(new QualifiedName("", "",
                 "encoder"), "1");
 
-            int[] data = currentCompressor.compress(node);
-
             atts.addAttributeWithAlgorithmData(
                 new QualifiedName("", "", "", "data"),
                 null,
                 EncodingAlgorithmIndexes.INT,
-                data);
+                currentCompressor.compress(node));  // Print data
         }
 
         if (hasChildren && !isProtoInstance) {
@@ -1622,7 +1628,7 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         } else {
             if (!isProtoInstance) {
                 try {
-                    if (isList.size() > 0) {
+                    if (!isList.isEmpty()) {
                         handler.startElement("",elementName,elementName, atts);
 
                         printNewLine();
@@ -1657,8 +1663,8 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
 
                 indentUp();
 
-                int midx = node.getFieldIndex("metadata");
-                VRMLFieldData fdata = node.getFieldValue(midx);
+                midx = node.getFieldIndex("metadata");
+                fdata = node.getFieldValue(midx);
 
                 // Print original metadata
                 if (fdata.nodeValue != null) {
@@ -1682,9 +1688,6 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                 handler.endElement("","MetadataInteger","MetadataInteger");
                 printNewLine();
 
-                // Print data
-                int[] data = currentCompressor.compress(node);
-
                 printIndent();
 
                 atts = new AttributesHolder();
@@ -1695,14 +1698,14 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                     new QualifiedName("", "", "", "value"),
                     null,
                     EncodingAlgorithmIndexes.INT,
-                    data);
+                    currentCompressor.compress(node)); // Print data
 
                 handler.startElement("","MetadataInteger","MetadataInteger", atts);
                 handler.endElement("","MetadataInteger","MetadataInteger");
                 printNewLine();
 
 
-                String emd = currentCompressor.getEncoderMetadata();
+                emd = currentCompressor.getEncoderMetadata();
 
                 if (emd != null) {
                     // TODO: Need to fix this
@@ -1776,15 +1779,22 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
             Iterator<VRMLFieldDeclaration> itr = fields.iterator();
 
             List<String[]> isList = new ArrayList<>();
+            VRMLFieldDeclaration decl;
+            VRMLFieldData data = null;
+            int idx, field_url, len, len2;
+            String is;
+            String[] urls;
+            StringBuilder buf;
+            boolean foundProtocol = false;
             while(itr.hasNext()) {
-                VRMLFieldDeclaration decl = itr.next();
+                decl = itr.next();
 
                 if(decl == null)
                     continue;
 
-                int idx = node.getFieldIndex(decl.getName());
+                idx = node.getFieldIndex(decl.getName());
 
-                String is = findIS(node, idx, isMap);
+                is = findIS(node, idx, isMap);
 
                 if (is == null) {
                     continue;
@@ -1799,16 +1809,15 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
 
             indentUp();
 
-            int field_url = node.getFieldIndex("url");
+            field_url = node.getFieldIndex("url");
 
-            VRMLFieldDeclaration decl = node.getFieldDeclaration(field_url);
+            decl = node.getFieldDeclaration(field_url);
 
-            VRMLFieldData data = null;
             try {
                 data = node.getFieldValue(field_url);
 
             } catch(InvalidFieldException e) {
-                StringBuilder buf = new StringBuilder("Can't get field: ");
+                buf = new StringBuilder("Can't get field: ");
                 buf.append(decl.getName());
                 buf.append(" for: ");
                 buf.append(node);
@@ -1818,15 +1827,13 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
                 buf.append(field_url);
 
                 errorReporter.errorReport(buf.toString(), null);
+                buf.setLength(0); // reset
             }
 
             if (upgrading) {
-                String[] urls = new String[data.stringArrayValues.length];
+                urls = new String[data.stringArrayValues.length];
 
-                boolean foundProtocol = false;
-
-                int len = urls.length;
-                int len2;
+                len = urls.length;
 
                 for(int i=0; i < len; i++) {
                     urls[i] = data.stringArrayValues[i];
@@ -1983,12 +1990,14 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
             int idx;
             boolean valReq;
 
+            VRMLFieldDeclaration decl;
+            VRMLFieldData val = null;
+            int access;
             while(itr.hasNext()) {
-                VRMLFieldDeclaration decl = itr.next();
+                decl = itr.next();
 
                 idx = proto.getFieldIndex(decl.getName());
-                VRMLFieldData val = null;
-                int access = decl.getAccessType();
+                access = decl.getAccessType();
 
                 if (access != FieldConstants.EVENTIN && access != FieldConstants.EVENTOUT) {
                     val = proto.getFieldValue(idx);
@@ -2093,22 +2102,24 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
         int len = url.length;
         StringBuilder urlAtt = new StringBuilder();
 
+        int pos, locpos;
+        String original, target;
         for(int i=0; i < len; i++) {
             urlAtt.append("\"");
 
             if (upgrading) {
-                int pos = url[i].indexOf(".wrl");
-                int locpos = url[i].indexOf("#");
+                pos = url[i].indexOf(".wrl");
+                locpos = url[i].indexOf("#");
 
                 if (pos >= 0) {
 
-                    String original = url[i];
+                    original = url[i];
                     url[i] = url[i].substring(0, pos);
 
                     url[i] = url[i] + encodingTo;
 
                     if (locpos > 0) {
-                        String target = original.substring(locpos);
+                        target = original.substring(locpos);
                         url[i] = url[i] + target;
                     }
                 }
@@ -2134,10 +2145,10 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
             Iterator<VRMLFieldDeclaration> itr = fields.iterator();
             int idx;
 
+            VRMLFieldDeclaration decl;
             while(itr.hasNext()) {
-                VRMLFieldDeclaration decl = itr.next();
+                decl = itr.next();
                 idx = proto.getFieldIndex(decl.getName());
-                VRMLFieldData val = null;
 
                 // Ignore metadata for EP
                 if (decl.getName().equals("metadata"))
@@ -2365,8 +2376,6 @@ public abstract class X3DRetainedSAXExporter extends BaseRetainedExporter
 
         // Print the field value
 
-        VRMLNode n;
-
         if (val != null) {
             switch(val.dataType) {
                 case VRMLFieldData.NODE_DATA: