Cleanup code.
Replaced pin state hack loop with proper state control.
Replaced method to count loops before sending new data using actual elapsed time. Allows to control loop speed without having to worry.