Updated coredata stuff so it only works on the main thread to minimize cross thread problems.