Fixed crashes with the gui.