refactored grid stuff so ET could use it too