pwm bugfix and scale factor