Fixed so cells don't loop through periodic neighbors.