Refactor into seprate compile module