Ensure correct thread for managed object contexts