improved build script to handle paths etc.