Moved startup logic from main to gui.