Fixed some bugs in semantic checker. Reused previous code for codeGenerator.