Load environment in a separate file, support parallel builds.

Closes #971.