Fixed bugs that happened while deleting panels