Fixed bugs in shepherd and api commands.