Bug fixes associated with converting SGPstateData to an environment