Changing pid to Map key

You may want to consider using a Registry. That saves you from tracking when those pids exit.