Modified version of ktoonsez's build script