More validation to prevent strange errors in generated code.
Full Java 6 compatibility: do not rely on Java 7 library or type-inference.
More code cleanup.