Bugfix: Fix shell hangs due to pipe corruptions

  -- reading from a pipe from different threads is not safe
     (fix in remote_object.run)
  -- plus some other minor modifications/fixes