PID controller implementation and code fix.