Fix delete function.
Refactoring and new helpers ko_new and ko_destroy.