Improve and fix build configuration scripts