refactor -- I'm not happy how everything is mutable, but I don't want scalaz on the browser.