Refactor compile script.