Merge pull request #544 from zonak/master

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