Initial work on app-state handling.
Next round on refactoring app state handling.

Not yet working, though.

Extracted DocumentLoader.