Made major correction to delete functionality.