Fixes bug in densities.cpp