Improved debug-printing, changed comments
Added tests
Made mtests.py to save output