Fix up some issues with the UI code... whole thing needs rethinking