Fix errors in motor driver