Refactored code generator using more linq
Simplified ToString()