Problem with unsigned long

//integers for the button
const int button = 7; //used for the button that inputs the morse
int buttonState = 0; //used to see if that button is on
const int contrButton = 8; //used for the control button
int contrButtonState = 0;
const int resetButton = 9; //button used to reset the morse
int resetButtonState = 0; 

//values
int secondCount = 0; //counts how many millis button is pressed
int pauseCount = 0; //counts how many millis the pause between button presses is
int Signallength = 0; //used to set millis of secondCount to usable number
int Pauselength = 0; //used to set millis of pauseCount to different states

//components for Void morse
int RefMorse; //is the reference for the input morse
char Lettre; //is the lettre that corresponds to a certain value

//problem value
unsigned long Morse = 0; // button presses get translated into morse using numbers saved in this

//for changing text to morse
char InputLettre; //is the lettre you typ in the serial monitor
char RefLettre; //is the lettre that LtoM uses as reference
char DisplayMorse[] = "tijde"; // the - and . that are shown on the serial monitor

void setup() {
  // only once
Serial.begin(9600);
pinMode(button, INPUT); //the normal button is the input in port 7
pinMode(contrButton, INPUT); //the control button is the input in port 8
pinMode(resetButton, INPUT); //the reset button is the input in port 9
char InputLettre = 0;
}




void loop() {

// 1 determine the button press length
  
buttonState = digitalRead(button); //reads normal button buttonstate
contrButtonState = digitalRead(contrButton); //reads control button buttonstate
resetButtonState = digitalRead(resetButton); //reads reset button buttonstate


if(buttonState == HIGH) { pauseCount = 0; //counts how long the button is pressed and sets the pausecount to 0
  secondCount = secondCount + 1; //adds 1 to secondCount every 40 milliseconds
    delay(40); //used to counter inaccuracy on button
  } else { secondCount = 0; // counts the pause between button presses and sets the secondCount to 0
  pauseCount = pauseCount + 1; //adds 1 to pauseCount every 40 milliseconds
   delay(40); //used to counter inaccuracy on button
    }


// 2 length to dots and dashes

// 2.1 typing the length for button presses
if(pauseCount == 0){ //if pausecount = 0, then button is pressed
if(secondCount > 2) { //adds 1 to signallength every 200 millis after button is pressed for 80 millis.
  Signallength = Signallength + 1;
   delay(200);} else {} //delay of 200 to counter using large numbers
  }
else {
  if(Signallength == 1 || Signallength == 2) { //if button is pressed for 200 or 400 millis
   Morse = Morse*10+1;  //adds a 1 to morse, that equals a dot
   Signallength = 0;  //reset the signallength to counter a loop
    } else {}
  if (Signallength >= 3) { //if button is pressed for more than 600 millis
    Morse = Morse*10+3; // adds a 3, which stand for a dash
    Signallength = 0; //reset the signallength to counter a loop
    } else {}
  }

  
// 2.2 typing the pause lengths

 if(Morse != 0 && secondCount == 0){ /if you already have a dot or dash and you button isn't pressed
  if(pauseCount >= 50 && pauseCount <= 100) { //looks if your button isn't pressed for between 1 and 4 seconds
 Pauselength = 1; //sets the pauselength to 1
     } else {}
  if(pauseCount >= 100) { //if the pause is longer than 4 seconds
   Pauselength = 2; //set pauselength switch to 2.
    } else {}  
  
   } else {
    if(Morse !=0) {
    if(Pauselength == 1) { // a 2 stands for a space between lettres.
 Morse = Morse*10+2; //if pauselength is 1, add a 2 to the morse
    Pauselength = 0;
     } else {}
  if(Pauselength == 2) { // a 5 stands for the end of the word
    Morse = Morse * 10 + 5;  // if pauselength equals 2, add a 5 to the end
   Pauselength = 0;
    } else {}  } else {}
    }


//read when a code is done with typing (so it ends in 2 or 5)

if(Morse % 2 == 0 && Morse !=0) //if you can divide morse by 2, then it ends in 2
{ Mtol(132,'A');
  Mtol(31112,'B');
  Mtol(31312, 'C');
  Mtol(3112, 'D');
  Mtol(12, 'E');
  Mtol(11312, 'F');
  Mtol(3312, 'G');
  Mtol(11112, 'H');
  Mtol(112, 'I');
  Mtol(13332, 'J');
  Mtol(3132, 'K');
  Mtol(13112,'L');
  Mtol(332,'M');
  Mtol(312,'N');
  Mtol(3332,'O');
  Mtol(13312,'P');
  Mtol(33132,'Q'); //problem value
  Mtol(1312,'R');
  Mtol(1112,'S');
  Mtol(32,'T');
  Mtol(1132, 'U');
  Mtol(11132,'V');
  Mtol(1332,'W');
  Mtol(31132,'X');
  Mtol(31332,'Y');
  Mtol(33112,'Z'); //problem value
  Mtol(133332, '1'); //problem value
  Mtol(113332, '2'); //problem value
  Mtol(111332, '3'); //problem value
  Mtol(111132, '4'); //problem value
  Mtol(111112, '5'); //problem value
  Mtol(311112, '6'); //problem value
  Mtol(331112, '7'); //problem value
  Mtol(333112, '8'); //problem value
  Mtol(333312, '9'); //problem value
  Mtol(333332, '0'); //problem value
  } else {}    

  if(Morse % 5 == 0 && Morse !=0) //if the morse is dividible by 5, then it is the end of a word
{ MtolP(135,'A');
  MtolP(31115,'B');
  MtolP(31315, 'C');
  MtolP(3115, 'D');
  MtolP(15, 'E');
  MtolP(11315, 'F');
  MtolP(3315, 'G');
  MtolP(11115, 'H');
  MtolP(115, 'I');
  MtolP(13335, 'J');
  MtolP(3135, 'K');
  MtolP(13115,'L');
  MtolP(335,'M');
  MtolP(315,'N');
  MtolP(3335,'O');
  MtolP(13315,'P');
  MtolP(33135,'Q'); //problem value
  MtolP(1315,'R');
  MtolP(1115,'S');
  MtolP(35,'T');
  MtolP(1135, 'U');
  MtolP(11135,'V');
  MtolP(1335,'W');
  MtolP(31135,'X');
  MtolP(31335,'Y');
  MtolP(33115,'Z'); //problem value
  MtolP(133335, '1'); //problem value
  MtolP(113335, '2'); //problem value
  MtolP(111335, '3'); //problem value
  MtolP(111135, '4'); //problem value
  MtolP(111115, '5'); //problem value
  MtolP(311115, '6'); //problem value
  MtolP(331115, '7'); //problem value
  MtolP(333115, '8'); //problem value
  MtolP(333315, '9'); //problem value
  MtolP(333335, '0'); //problem value
  } else {}    
 
// 3 makes that your morse doesn't do weird things
if(Morse < 0) { //if it goes negative
  Morse = 0; //rest to 0
  } else {}
if(Morse > 9999999) { //if it goes on too long
  Morse = 0; //reset to 0
  } else {}


//4 control button
 if (contrButtonState == HIGH) { //if control button is pressed
  Serial.print("Morse = "); //print your morse with the 1,2,3s and 5s
  Serial.println(Morse);
  delay(200);  //delay for the button
  } else {}

//5 reset button
 if (resetButtonState == HIGH) {
  Morse=0;
  } else {}
//lezen lezen lezen
if (Serial.available() > 0) {    
 InputLettre = Serial.read();}   // set equal lettre to what you're typing

Ltom(".- /",'a'); //if you typ a, print .- / same for the rest
Ltom("-... /",'b');
Ltom("-.-. /",'c');
Ltom("-.. /",'d');
Ltom(". /",'e');
Ltom("..-. /",'f');
Ltom("--. /",'g');
Ltom(".... /",'h');
Ltom(".. /",'i');
Ltom(".--- /",'j');
Ltom("-.- /",'k');
Ltom(".-.. /",'l');
Ltom("-- /",'m');
Ltom("-. /",'n');
Ltom("--- /",'o');
Ltom(".--. /",'p');
Ltom("--.- /",'q');
Ltom(".-. /",'r');
Ltom("... /",'s');
Ltom("- /",'t');
Ltom("..- /",'u');
Ltom("...- /",'v');
Ltom(".-- /",'w');
Ltom("-..- /",'x');
Ltom("-.-- /",'y');
Ltom("--.. /",'z');

}

void Mtol(int RefMorse, char Lettre) { //Mtol= Morse to letter
if(Morse == RefMorse) //if your morse equals one of the references
 {Serial.print(Lettre); //print the right lettre to your serial monitor
 Morse=0; //reset morse
 } else {}
}


void MtolP(int RefMorse, char Lettre) { //MtolP= Morse to letter with Pause
if(Morse == RefMorse) //same as above
 {Serial.print(Lettre);
 Serial.print(" ");//same as above
 Morse=0; //same as above
 } else {}
}

void Ltom(char DisplayMorse[], char RefLettre) { //Ltom = letter to Morse
  if(InputLettre == RefLettre) { //if your input equals a reference
    Serial.print(DisplayMorse); //print the right dots and dashes
    InputLettre == 0; //reset to 0
    }
  }

I’m trying to make a system that translates buttonpresses with morse to lettres.
As my main variable i’m using an unsigned long that I add and multiply with different values to get my morse.
But I’m having a problem, whenever my unsigned long goes 33000 it takes my arduino too long to reference this code and adds another value at the end, which breaks my code.
I have tried adding delays and changing the unsigned long with other values, but nothing seems to help it.
What am I doing wrong?

void Mtol(int RefMorse, char Lettre) { //Mtol= Morse to letter

RefMorse needs to be an unsigned long here, too. (And probably other places.)