Index: lab3/errors.h
===================================================================
--- lab3/errors.h	(revision 66)
+++ lab3/errors.h	(revision 67)
@@ -1,5 +1,5 @@
-#ifndef _ERRORS_H_
-#define _ERRORS_H_
+#ifndef ERRORS_H_INCLUDED
+#define ERRORS_H_INCLUDED
 
 enum errors {
     SUCCESS = 0,    /* @brief Sucessful */
@@ -12,4 +12,4 @@
     TIMEOUT_ERROR,  /* @brief Timeout error */
 };
 
-#endif /* end of include guard: _ERRORS_H_ */
+#endif // ERRORS_H_INCLUDED
Index: lab3/kbc.c
===================================================================
--- lab3/kbc.c	(revision 66)
+++ lab3/kbc.c	(revision 67)
@@ -4,67 +4,76 @@
 
 #include "kbc_macros.h"
 #include "utils.h"
+#include "errors.h"
 
 int (unsubscribe_interrupt)(int *interrupt_id) {
-    if (interrupt_id == NULL) return 1;
-    return sys_irqrmpolicy(interrupt_id);
+    if (interrupt_id == NULL) return NULL_PTR;
+    if(sys_irqrmpolicy(interrupt_id)) return UNSBCR_ERROR;
+    return SUCCESS;
 }
 
 int (kbc_read_cmd)(uint8_t *cmd){
-    if(kbc_issue_cmd(READ_KBC_CMD)) return 1;
-    if(kbc_read_byte(cmd)) return 1;
-    return 0;
+    int ret = 0;
+    if((ret = kbc_issue_cmd(READ_KBC_CMD))) return ret;
+    if((ret = kbc_read_byte(cmd))) return ret;
+    return SUCCESS;
 }
 
 int (kbc_change_cmd)(uint8_t cmd){
-    if(kbc_issue_cmd(WRITE_KBC_CMD)) return 1;
-    if(sys_outb(KBC_CMD_ARG, cmd)) return 1;
-    return 0;
+    int ret = 0;
+    if((ret = kbc_issue_cmd(WRITE_KBC_CMD))) return ret;
+    if((ret = kbc_issue_arg(cmd))) return ret;
+    return SUCCESS;
 }
 
 int (kbc_restore_keyboard)(){
+    int ret = 0;
     uint8_t cmd = 0;
-    if(kbc_read_cmd(&cmd)) return 1;
+    if((ret = kbc_read_cmd(&cmd))) return ret;
     cmd = (cmd | INT_KBD) & (~DIS_KBD) ;
-    if(kbc_change_cmd(cmd)) return 1;
-    return 0;
+    if((ret = kbc_change_cmd(cmd))) return ret;
+    return SUCCESS;
 }
 
 int (kbc_issue_cmd)(uint8_t cmd){
+    int ret = 0;
     uint8_t stat;
     for(int i = 0; i < KBC_NUM_TRIES; ++i){
-        if(util_sys_inb(STATUS_REG, &stat)) return 1;
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
         if((stat&IN_BUF_FULL) == 0){
-            if(sys_outb(KBC_CMD, cmd)) return 1;
-            return 0;
+            if(sys_outb(KBC_CMD, cmd)) return WRITE_ERROR;
+            return SUCCESS;
         }
         tickdelay(micros_to_ticks(DELAY));
     }
-    return 1;
+    return TIMEOUT_ERROR;
 }
 
 int (kbc_issue_arg)(uint8_t arg){
+    int ret = 0;
     uint8_t stat;
     for(int i = 0; i < KBC_NUM_TRIES; ++i){
-        if(util_sys_inb(STATUS_REG, &stat)) return 1;
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
         if((stat&IN_BUF_FULL) == 0){
-            if(sys_outb(KBC_CMD_ARG, arg)) return 1;
-            return 0;
+            if(sys_outb(KBC_CMD_ARG, arg)) return WRITE_ERROR;
+            return SUCCESS;
         }
         tickdelay(micros_to_ticks(DELAY));
     }
-    return 1;
+    return TIMEOUT_ERROR;
 }
 
 int (kbc_read_byte)(uint8_t *byte){
+    int ret = 0;
     uint8_t stat;
     while(true){
-        if(util_sys_inb(STATUS_REG, &stat)) return 1;
+        if((ret = util_sys_inb(STATUS_REG, &stat))) return ret;
         if((stat&OUT_BUF_FUL) && (stat&AUX_MOUSE)==0){
             if(stat & (PARITY_ERROR | TIME_OUT_REC)) return 1;
-            if(util_sys_inb(OUTPUT_BUF, byte)) return 1;
-            else return 0;
+            if((ret = util_sys_inb(OUTPUT_BUF, byte))) return ret;
+            else return SUCCESS;
         }
         tickdelay(micros_to_ticks(DELAY));
     }
+    return TIMEOUT_ERROR;
 }
Index: lab3/kbc.h
===================================================================
--- lab3/kbc.h	(revision 66)
+++ lab3/kbc.h	(revision 67)
@@ -3,8 +3,8 @@
  * actually also manages the mouse)
  */
 
-#ifndef _KBC_FUNC_H_
-#define _KBC_FUNC_H_
+#ifndef KBC_H_INCLUDED
+#define KBC_H_INCLUDED
 
 /**
  * @brief Unsubcribes Interrupts
@@ -60,5 +60,4 @@
  */
 int (kbc_read_byte)(uint8_t *byte);
 
-
-#endif
+#endif //KBC_H_INCLUDED
Index: lab3/kbc_macros.h
===================================================================
--- lab3/kbc_macros.h	(revision 66)
+++ lab3/kbc_macros.h	(revision 67)
@@ -1,5 +1,5 @@
-#ifndef _KBC_H_
-#define _KBC_H_
+#ifndef KBC_MACROS_H_INCLUDED
+#define KBC_MACROS_H_INCLUDED
 
 /* KBC IRQ Line */
 
@@ -53,4 +53,4 @@
 #define DIS_KBD         BIT(4)  /* @brief Disable Keyboard */
 #define DIS_MOU         BIT(5)  /* @brief Disable Mouse */
 
-#endif
+#endif //KBC_MACROS_H_INCLUDED
Index: lab3/keyboard.c
===================================================================
--- lab3/keyboard.c	(revision 66)
+++ lab3/keyboard.c	(revision 67)
@@ -14,13 +14,12 @@
     return SUCCESS;
 }
 
-int done = 1;
-int sz = 1;
+int keyboard_done = 1;
+int scancode_sz = 1;
 int got_error_keyboard = 0;
 
 void (kbc_ih)(void) {
-    if(done) sz = 1;
-    else     sz++;
+    if(keyboard_done) scancode_sz = 0;
     uint8_t status = 0;
     got_error_keyboard = 0;
     if (util_sys_inb(STATUS_REG, &status)) {
@@ -40,8 +39,9 @@
         got_error_keyboard = 1;
         return;
     }
-    scancode[sz-1] = byte;
-    done = !(TWO_BYTE_CODE == byte);
+    scancode[scancode_sz] = byte;
+    scancode_sz++;
+    keyboard_done = !(TWO_BYTE_CODE == byte);
 }
 
 int (keyboard_poll)(uint8_t bytes[], uint8_t *size){
Index: lab3/keyboard.h
===================================================================
--- lab3/keyboard.h	(revision 66)
+++ lab3/keyboard.h	(revision 67)
@@ -14,8 +14,8 @@
 int (subscribe_keyboard_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
 
 uint8_t scancode[2];
-int done;
-int sz;
+int keyboard_done;
+int scancode_sz;
 int got_error_keyboard;
 
 /**
Index: lab3/lab3.c
===================================================================
--- lab3/lab3.c	(revision 66)
+++ lab3/lab3.c	(revision 67)
@@ -56,8 +56,8 @@
                 case HARDWARE: /* hardware interrupt notification */
                     if (msg.m_notify.interrupts & kbc_irq) { /* subscribed interrupt */
                         kbc_ih();
-                        if(done)
-                            kbd_print_scancode(!(scancode[sz-1] & BREAK_CODE_BIT), sz, scancode);
+                        if(keyboard_done)
+                            kbd_print_scancode(!(scancode[scancode_sz-1] & BREAK_CODE_BIT), scancode_sz, scancode);
                         if (scancode[0] == ESC_BREAK_CODE) good = 0;
                     }
                     break;
@@ -126,8 +126,8 @@
                     }
                     if (msg.m_notify.interrupts & kbc_irq) { /// subscribed interrupt
                         kbc_ih();
-                        if(done) {
-                            kbd_print_scancode(!(scancode[sz-1] & BREAK_CODE_BIT), sz, scancode);
+                        if(keyboard_done) {
+                            kbd_print_scancode(!(scancode[scancode_sz-1] & BREAK_CODE_BIT), scancode_sz, scancode);
                             time = 0;
                             no_interrupts = 0;
                             if (scancode[0] == ESC_BREAK_CODE) good = 0;
