All functionality done, time to refactor
Refactored to make DRY-er, but I think the code is worse on the whole