Code refactoring, work on Core Data stack