latest commit from jia's machine : now saving env state right before we exit the sim