Fix for saving of trial data and for environments

Post commit code review : Cyrus Venn Casada