Fix an issue with the setting of 'window.ENV'.
Merge pull request #544 from zonak/master

Fix an issue caused by setting 'window.ENV' at the wrong point