code cleanup: organize environment object grid methods, split nested classes