611 lines of code later and 7 refactors, solution complete