now supports building for staging environment, improved error reporting