Fix rounding issues and density term.
Merge pull request #1404 from akbargumbira/develop

Fix rounding issues and density term.