Moved part of UI logic out of DatabaseWrapper