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