Fixed bug in environment settings code.