Performance improvements

Rewrite access functions when the cache is populated
	this avoids pointless conditionals
Move the boundary functions from the cell definition
to the grid definition
	this decreases the size of cell functions and theoretically
	the total memory footprint.