Fix a lot of bugs around the ui