Fixed ports and added digital and relay ports, MXP ports still missing.
Refactored out control loops into their own library.