Refactor some parts of the compiler.