Various refactoring, working towards a better UI