Single, Double, Long, VeryLong click TM1638

I have tried to modify this code
ArduinoDoubleClickNonterupptOrDelay
to allow it to work with a tm1638
I am working on an ESP8266 because that’s what I got hooked up at the moment.
Instead of using a bool for each status I wanted to use a status bit in a single unsigned 8bit int.
this is because a tm1638 can have 16 or more buttons if they are cascaded.
so 8 bytes (status bool) * 16 or more buttons, the memory load starts to become significant.
So I have included my entire code so far. The plan is to create a struct or class that will be declared for each button
So far as a set of functions it works for single click and double click. It will read 1 short hold function but after that it will only work with a long hold function and not be able to register any other events.
The logic is meant to be a direct copy of the other code mentioned above with a few names changed. I still don’t completely understand the logic of the original code however it should translate without problem into this method.
Anyone know why it hangs with a ShortHold press?
All the serial prints are there to try and trace the code.

/*
Program to Setup MultipleClick Funcitons 
with tm1638
*/
#include <TM1638.h>
#define LED_COLOR_NONE 0b00
#define LED_COLOR_RED 0b01
#define LED_COLOR_GREEN 0b10
#define LED_COLOR_ORANGE 0b11

#define tm1638_dt 13
#define tm1638_ck 12
#define tm1638_Button_Module_sb 14
#define tm1638_Time_Module_sb 2
#define tm1638_Date_Module_sb 0 
#define tm1638_intensity 3 

#include <TimeLib.h>
#include <TM1638.h>


#define time_debounce 20
#define time_InterDoubleClick 200
#define time_ShortHold 800
#define time_LongHold 1500

#define buttonLast			 	0b00000001
#define waitForNextDown		 	0b00000010
#define waitForNextUp			0b00000100
#define singleOK				0b00001000
#define ignoreUp				0b00010000
#define holdEventPast			0b00100000
#define longHoldEventPast		0b01000000




TM1638 button_Module(tm1638_dt, tm1638_ck, tm1638_Button_Module_sb);
uint8_t checkButton(bool);

void setup() 
{
	Serial.begin(115200);
	button_Module.setupDisplay(true, tm1638_intensity);
}

void loop() 
{
	static bool ButtonPressed = false;
	byte buttonRead  = button_Module.getButtons();
	if (buttonRead & 0b00000001) 
	{
		//Serial.println(buttonRead);
		ButtonPressed = true;
	}
	else 
	{
		ButtonPressed = false;
	}
	uint8_t ResultValue = checkButton(ButtonPressed);
	
	if (ResultValue > 0 ) 
	{
		Serial.print("->>>>");
		Serial.print(ResultValue);
		Serial.println("<<<<<------");
	}	
	
}


uint8_t checkButton(bool buttonVal)
{
	static uint8_t ButtonStatusBits = singleOK;
	static long buttonDownTime = -1;         // time the button was pressed down
	static long buttonUpTime = -1;           // time the button was released
	uint8_t returnEventCode = 0;
	Serial.print("->>");
	Serial.println(ButtonStatusBits,BIN);
	// Button pressed down
	if (buttonVal && !(ButtonStatusBits & buttonLast) && (millis() - buttonUpTime) > time_debounce)
	{
	   
	   Serial.print("A");
	   buttonDownTime = millis();
	   ButtonStatusBits = ButtonStatusBits | singleOK & ~ignoreUp & ~holdEventPast & ~longHoldEventPast;
	   if ((millis()-buttonUpTime) < time_InterDoubleClick && !(ButtonStatusBits & waitForNextUp) && (ButtonStatusBits & waitForNextDown))
	   {
			Serial.print("B");
			ButtonStatusBits =ButtonStatusBits | waitForNextUp;
	   }
	   else
	   {
			Serial.print("C");
			ButtonStatusBits = ButtonStatusBits & ~waitForNextUp;
	   }
	   ButtonStatusBits = ButtonStatusBits & ~waitForNextDown; // = false
	}
	// Button released
	else if (!buttonVal && (ButtonStatusBits & buttonLast) && ((millis() - buttonDownTime) > time_debounce))
	{
	   Serial.print("D");
	   if (!(ButtonStatusBits & ignoreUp))
	   {
		   Serial.print("E");
		   buttonUpTime = millis();
		   if (!(ButtonStatusBits & waitForNextUp))
		   {
				Serial.print("F");
				ButtonStatusBits = ButtonStatusBits | waitForNextDown;// = true;
		   }
		   else
		   {
			   Serial.print("G");
			   returnEventCode = 2;
			   ButtonStatusBits = ButtonStatusBits & ~waitForNextUp & ~waitForNextDown & ~singleOK;
		   }
	   }
	}
	// Test for normal click returnEventCode: time_InterDoubleClick expired
	if (!buttonVal && (millis()-buttonUpTime) >= time_InterDoubleClick && (ButtonStatusBits & waitForNextDown ) && !(ButtonStatusBits & waitForNextUp ) &&  (ButtonStatusBits & singleOK) && (returnEventCode != 2))
	{
		Serial.print("H");
		returnEventCode = 1;
		ButtonStatusBits = ButtonStatusBits  & ~waitForNextDown; // = false;
	}
/* 	if (!buttonVal && (ButtonStatusBits & holdEventPast) && !(ButtonStatusBits & longHoldEventPast ))
	{
		Serial.print("J");
		returnEventCode = 3;
		ButtonStatusBits &= ~holdEventPast;
	} */
	// Test for hold
	if (buttonVal && (millis() - buttonDownTime) >= time_ShortHold)
	{
	   Serial.print("K");
	   // Trigger "normal" hold
	   if (!(ButtonStatusBits & holdEventPast))
	   {
		   returnEventCode = 3;
		   Serial.print("L");
		   ButtonStatusBits = ButtonStatusBits | ignoreUp | holdEventPast & ~waitForNextUp & ~waitForNextDown ;
	   }
	   // Trigger "long" hold
	   if ((millis() - buttonDownTime) >= time_LongHold)
	   {
		   Serial.print("M");
		   if (!(ButtonStatusBits & longHoldEventPast))
		   {
			   Serial.print("N");
			   //ButtonStatusBits =0;
			   returnEventCode = 4;
			   ButtonStatusBits = ButtonStatusBits | longHoldEventPast; // = true;
		   }
	   }
	}
	//DCwaiting -> waitForNextDown
//DConUp -> waitForNextUp
	if (buttonVal)
	{
		Serial.println("O");
		ButtonStatusBits = ButtonStatusBits | buttonLast;
	}
	else
	{
		Serial.print("P");
		ButtonStatusBits =ButtonStatusBits & ~buttonLast;
	}
	Serial.print("Q");
	Serial.println(ButtonStatusBits,BIN);
	return returnEventCode;
}