Split off the spatial grid functionality into separate source files.