major refactoring of compiler