Javadocs added for code generation. Refactored code generation.