Bug fixes

Fixed several bugs where local variables were being set instead of
global variables.  Updated the init method to read the initial state of
the IO pins instead of setting them to 0.