Refactor and fix updater bugs

It's still a really messy file with a whole bunch of state and shit.
Needs further rewriting with better separation of concerns, but this
commit at least fixes the bugs.