Major refactoring to abstract away the backend and to drive the UI via events.