Completely separate heapEnv from Env. Fix other bugs found from testing
the os project.