fixed some bugs with coreData