     else if (m->Handling == LatchingOn) {
       // Default the value to "on"
       LastValue[i] = 0x7f;
+      LatchState[i] = 1;
     }
     else {
       // Default the value to "off"
       LastValue[i] = 0;
+      LatchState[i] = 0;
     }
   }
 }


    case LatchingOff:
    case LatchingOn:
      // Fetch current latch state based on last value sent
      if (LastValue[i] < 64) {
        state = 0;
      }
      else {
        state = 1023;
      }

      // Toggle state on button press
      if (PinState[pinNum] < 512 && NewState[pinNum] >= 512) {
        state = 1023 - state;
        changed = 1;
      }
      else {
        changed = 0;
      }
      break;

    default:

    }
  }

  // Initialize EventList, NumEvents, LastValue, LatchState
  NumEvents = count;
  EventList = (EventMap *)realloc (EventList, NumEvents * sizeof (*EventList));
  memcpy(EventList, &DefaultEventList[i], NumEvents * sizeof (*EventList));

  LastValue = (uint8_t *)realloc (LastValue, NumEvents * sizeof (*LastValue));
  memset(LastValue, 0, NumEvents * sizeof (*LastValue));

  LatchState = (uint8_t *)realloc (LatchState, NumEvents * sizeof (*LatchState));
  memset(LatchState, 0, NumEvents * sizeof (*LatchState));

  // Send any initialization events, and initialize LastValue[]

