Code improvements and small ui bugfixes