Fixed possible crashes after copying the Gui object