Complete refactor.  Now it's actually pretty cool.