Improved handling of bad pids.