Now with events

Created a new Compile object to offload the compile process and clean up the code structure.