Refactoring code. Improving documentation.
Changing error checks from if statements to assert statements.