Major refactoring. Somethings really shouldn't be public api.