Fixed the InitPIDstate function

To cover all the cases.