Refactoring + WIP version of GUI

Even if we don't work on the GUI, I made other change that could be worth keeping.