Moved a few classes around and game them new namespaces.
Fixed a number of bugs.
ApplicationStateManager now inherits from Application.