Refactored compilation to function
Basic multithreading of compilation