Tightened up interfaces.

- Added more formal interfaces.
- Refactored some logic into common base classes.
- Stricter visibility for class members.
- Added new getter methods where necessary.