Fix delete instance function