Refactored building environment in main