Ui

Some refactoring prior to working on fonts and ui. Basically, splitting some classes into more generic base classes for better code reuse.