fix multiple bugs in compiler