Some changes to PID and added statistics