ensuring proper cleanup for core data