Refactored the compile script and some related things