Added json, fixed several issues with code generator