   return false;
 }
 
-/* Returns address of card - returns 65535 if card is not found */
+/* Returns address of card - returns 0xFFFF if card is not found */
 int16_t findCardOffset(const card_t c){
   uint16_t addr;
-  uint16_t last_addr = 1024-sizeof(card_t); // EEPROM size minus element size
-  for(addr = 0; addr <= last_addr; addr = addr + sizeof(card_t)){
+  uint16_t last_addr = EEPROM_SIZE - sizeof(card_t); // EEPROM size minus element size
+  for(addr = 0; addr <= last_addr; addr += sizeof(card_t)){
     if(EEPROM_compareAnything(addr,c.uid)){ // If bytes at address match, ok!
       //Serial.println(addr);
       return addr;
     }
   }
-  return 65535; // Error value
+  return 0xFFFF; // Error value
 }
 
 int16_t findFreeCardSpot(){
-  uint16_t credits = 0;
+  card_credits_t credits = 0;
   uint16_t addr = sizeof(card_uid_t); // Offset pointer, so we are looking at the card.credits
-  uint16_t last_addr = 1024-sizeof(card_t); // EEPROM size minus size of one element
-  for(addr; addr <= last_addr; addr = addr + sizeof(card_t)){
-    if(EEPROM_compareAnything(addr,credits)){ // If bytes at address match, ok!
+  uint16_t last_addr = EEPROM_SIZE - sizeof(card_credits_t); // EEPROM size minus size of one element
+  for(addr; addr <= last_addr; addr += sizeof(card_t)){
+    if(EEPROM_compareAnything(addr, credits)){ // If bytes at address match, ok!
       //Serial.println(addr-sizeof(card_uid_t));
       return addr-sizeof(card_uid_t); // Offset pointer again, so it points to beginning of card_t
     }
   }
-  return 65535; // Error value
-}
-
-int speakerOut = 9;               
+  return 0xFFFF; // Error value
+}
 
 int tone_ = 0;
 
 void BEEP(uint8_t n){
   unsigned char delayms = 100;
   beepp(delayms);
-  for(int i=1;i<n;i++){
+  for(uint8_t i=1;i<n;i++){
     delay(delayms);
     beepp(delayms);
   }
 }
 
 void beepp(unsigned char delayms){
-  analogWrite(9, 100);     // Almost any value can be used except 0 and 255
+  analogWrite(speakerOutPin, 100);     // Almost any value can be used except 0 and 255
                            // experiment to get the best tone
   delay(delayms);          // wait for a delayms ms
-  analogWrite(9, 0);       // 0 turns it off
+  analogWrite(speakerOutPin, 0);       // 0 turns it off
 }                         
-
-

      if(recieve_error == 1){BEEP(4);return;}

      if(credits_in_machine == 0){ // Attempt withdrawal               ## WITHDRAW
        if(addr == 65535){ // New card!
          // ERR Beep + display "NO CREDITS"?
          //Serial.println("NO CREDITS - UNKNOWN CARD");
          Serial.print("N");
          BEEP(1);
          // Halt PICC
          mfrc522.PICC_HaltA();

  // Now a card is selected. The UID and SAK is in mfrc522.uid.

  // Dump UID
    if(millis() - lastCardScan > timeBetweenScans){
      lastCardScan = millis();
      // Some user feedback
      BEEP(1);
