Index: proj/Makefile
===================================================================
--- proj/Makefile	(revision 152)
+++ proj/Makefile	(revision 153)
@@ -1,6 +1,6 @@
 PROG=proj
 
-SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c
+SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c
 
 CPPFLAGS += -pedantic -D __LCOM_OPTIMIZED_
 
Index: proj/keyboard.h
===================================================================
--- proj/keyboard.h	(revision 152)
+++ proj/keyboard.h	(revision 153)
@@ -5,6 +5,13 @@
 #ifndef KEYBOARD_H_INCLUDED
 #define KEYBOARD_H_INCLUDED
 
+/**
+ * @brief Subscribes Keyboard Interrupts and disables Minix Default IH
+ * @param interrupt_bit Bit of Interrupt Vector that will be set when Keyboard Interrupt is pending
+ * @param interrupt_id Keyboard Interrupt ID to specify the Keyboard Interrupt in other calls
+ * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
+ * @see {_ERRORS_H_::errors}
+ */
 int (subscribe_kbc_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
 
 uint8_t scancode[2];
Index: proj/proj.c
===================================================================
--- proj/proj.c	(revision 152)
+++ proj/proj.c	(revision 153)
@@ -18,6 +18,7 @@
 #include "keyboard.h"
 #include "mouse.h"
 #include "utils.h"
+#include "interrupts_func.h"
 
 int main(int argc, char* argv[]) {
 
@@ -58,37 +59,10 @@
     /// loop stuff
     int ipc_status, r;
     message msg;
-    /// Keyboard interrupt handling
-    uint8_t kbc_irq_bit = KBC_IRQ;
-    int kbc_id = 0;
-    int kbc_irq = BIT(kbc_irq_bit);
-    if (subscribe_kbc_interrupt(kbc_irq_bit, &kbc_id)) {
-        return 1;
-    }
 
-    /// Timer interrupt handling
-    //const uint32_t frequency = sys_hz(); // Frequency asummed at 60Hz
-    uint8_t timer_irq_bit = TIMER0_IRQ;
-    int timer_id = 0;
-    int timer_irq = BIT(timer_irq_bit);
-    if(subscribe_timer_interrupt(timer_irq_bit, &timer_id)) {
-        if (vg_exit()) printf("%s: vg_exit failed to exit to text mode.\n", __func__);
-        if (free_memory_map()) {
-            printf("%s: lm_free failed\n", __func__);
-        }
-        return 1;
-    }
+    /// subscribe interrupts
+    if (subscribe_all()) return 1;
 
-    /// Mouse interrupt handling
-    uint8_t mouse_irq_bit = MOUSE_IRQ;
-    int mouse_id = 0;
-    int mouse_irq = BIT(mouse_irq_bit);
-
-    if (subscribe_mouse_interrupt(mouse_irq_bit, &mouse_id)) return 1; // subscribes mouse interrupts in exclusive mode
-    if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications
-    if (mouse_set_data_report(true)) return 1; // enables mouse data reporting
-    if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
-
     /// cycle
     int good = 1;
     while (good) {
@@ -100,17 +74,12 @@
         if (is_ipc_notify(ipc_status)) { /* received notification */
             switch (_ENDPOINT_P(msg.m_source)) {
                 case HARDWARE: /* hardware interrupt notification */
-                    if (msg.m_notify.interrupts & kbc_irq) { /* subscribed interrupt */
-                        kbc_ih();
-                        if (scancode[0] == ESC_BREAK_CODE) good = 0;
+                    for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
+                        if (msg.m_notify.interrupts & n) {
+                            interrupt_handler(i);
+                        }
                     }
-                    if (msg.m_notify.interrupts & timer_irq) { /* subscribed interrupt */
-                        timer_int_handler();
-                    }
-
-                    if (msg.m_notify.interrupts & mouse_irq) { /* subscribed interrupt */
-                        mouse_ih();
-                    }
+                    if (scancode[0] == ESC_BREAK_CODE) good = 0;
                     break;
                 default:
                     break; /* no other notifications expected: do nothing */
@@ -120,23 +89,10 @@
         }
     }
 
-    // Unsubscribe Keyboard interrupts
-    if (unsubscribe_interrupt(&kbc_id)) {
-        return 1;
-    };
+    // Unsubscribe interrupts
+    if (unsubscribe_all()) return 1;
 
-    // Unsubscribe Timer Interrupts
-    if (unsubscribe_interrupt(&timer_id)) {
-        return 1;
-    }
 
-    // Unsubscribe Mouse Interrupts
-    if (sys_irqdisable(&mouse_id)) return 1; // temporarily disables our interrupts notifications
-    if (mouse_set_data_report(false)) return 1; // enables mouse data reporting
-    if (sys_irqenable(&mouse_id)) return 1; // re-enables our interrupts notifications
-    if (unsubscribe_interrupt(&mouse_id)) return 1; // unsubscribes interrupts
-
-    
     if (vg_exit()) {
         printf("%s: vg_exit failed to exit to text mode.\n", __func__);
         if (free_memory_map()) printf("%s: lm_free failed\n", __func__);
@@ -148,7 +104,7 @@
         return 1;
     }
 
-    
+
     #ifdef DIOGO
         hello
     #endif
