Added a bunch of assertions and made sure all math is done using python's decimal module