Fix invalid metadata on delete.
Refactoring.
Merge pull request #6 from nbeloglazov/fix-meta-on-delete

Fix meta on delete