Build script refactoring