Fixed minor bug that occasionally gave error about reallocating densityPerturbation