Re-structured the 2D density estimator for ease of deployment.