Prevent overflows in totalNeighborhoods.