The Great Refactor

aka, the day when I was stupid and decided to write the entire thing.