Fix rounding issues and density term.