Add some defensive pid checks