Massive refactoring to add a pile of things.