Rewrite PWM management code.

The PWM period can now be set for each individual output pin.

Also, hopefully tackle some weirdness with setting the duty cycle.

These changes still need to be tested.