More work on compile task plus some refactoring.