fixed PID restart issue and added an option to checkpoint after some fixed time interval