PWM output now works, and is tested.
Cleaned up the code structure a bit too.