Removed core data boilerplate code
Fixed memory management