Fixed threading issue in shepherd.api