Fixed logging, added checks for nil contexts and some more NSManagedObject work