Refactor and lots of other stuff.