Fix weird crashes when opening GUIs in some cases