Big restructure of UI code
Import improvements