Big refactoring completed. Everything prepared for the separation of core and gui.