Fixed a problem where core.environment was not used in bootstrap() when necessary, fixes #581 (also made that code a little more logical in structure)