build.py updates taken from new dev branch