improved core data thread handling