Refactored lots of stuff.