pid/gid mess improved

Not sure if dependencies are correct. please check.
indentation is too keep here i think, should be 2 spaces