Refactor compile script