Large refactoring of classes to keep things more consistent.