Fix for problem regarding proper saving of environment related trial data

Code review : Daniel Jao