Added code to ensure that each PID is unique.