Moved most of app-building functionality out of context manager.