More refactoring to split gui from implementation