Class rearchitecture

See commit messages.