Added mechanism to check the battery, added port detect data structure, updated the LEDs test routine, refactored some code into the implementation file