Fix for wrong call to RemoveEnvironment

Fixed some error caused by wrong call to RemoveEnvironment.