Fixed blinking issue
Fixed various errors in typechecking and codegen