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)
merge 86c61aafeec3d896205181a0902e393fb2a367d2, refs #581