Added comments explaning some of the more confusing portions, added asserts, and re-wrote the cumsum code to be more numerically stable.
Merge branch 'refactor' of https://github.com/nikhilRP/idr into refactor