Fix bug: when grid is too sparse, could lead to out of bound array access. Now make sure there should be at least 2 grid for no matter what gridDensity.