More refactoring/improvements/gui work