Refactoring shared compiler code for less duplication.