Refactor compile scripts