Added realtime buffer to PID, re-ordered functions to more logical order and to match header file