Move non-window-related initialisation to ui_init. All functions after ui_init can now assume display and other globals are valid.