Fixed several bugs in generated code. Now I mostly need to work on the 'look' of the code