Fix a bug where deleting an element during one of it's events would cause a crash and/or script error.