Code generation now generates correct code for some test cases, various fixes to parser.