Index: uspace/drv/usbhid/hiddev.c
===================================================================
--- uspace/drv/usbhid/hiddev.c	(revision 27270db1d62255b3767750c55bc91df14a0b8216)
+++ uspace/drv/usbhid/hiddev.c	(revision 1c6c4092670c8cef1e8e1beaacf8cede220ab188)
@@ -270,4 +270,27 @@
 /*----------------------------------------------------------------------------*/
 
+void usbhid_dev_free(usbhid_dev_t **hid_dev)
+{
+	if (hid_dev == NULL || *hid_dev == NULL) {
+		return;
+	}
+	
+	// free the report descriptor
+	if ((*hid_dev)->report_desc != NULL) {
+		free((*hid_dev)->report_desc);
+	}
+	// destroy the parser
+	if ((*hid_dev)->parser != NULL) {
+		usb_hid_free_report_parser((*hid_dev)->parser);
+	}
+	
+	// TODO: cleanup pipes
+	
+	free(*hid_dev);
+	*hid_dev = NULL;
+}
+
+/*----------------------------------------------------------------------------*/
+
 int usbhid_dev_init(usbhid_dev_t *hid_dev, ddf_dev_t *dev, 
     usb_endpoint_description_t *poll_ep_desc)
Index: uspace/drv/usbhid/hiddev.h
===================================================================
--- uspace/drv/usbhid/hiddev.h	(revision 27270db1d62255b3767750c55bc91df14a0b8216)
+++ uspace/drv/usbhid/hiddev.h	(revision 1c6c4092670c8cef1e8e1beaacf8cede220ab188)
@@ -69,4 +69,6 @@
 usbhid_dev_t *usbhid_dev_new(void);
 
+void usbhid_dev_free(usbhid_dev_t **hid_dev);
+
 int usbhid_dev_init(usbhid_dev_t *hid_dev, ddf_dev_t *dev,
     usb_endpoint_description_t *poll_ep_desc);
Index: uspace/drv/usbhid/kbddev.c
===================================================================
--- uspace/drv/usbhid/kbddev.c	(revision 27270db1d62255b3767750c55bc91df14a0b8216)
+++ uspace/drv/usbhid/kbddev.c	(revision 1c6c4092670c8cef1e8e1beaacf8cede220ab188)
@@ -41,4 +41,5 @@
 #include <io/keycode.h>
 #include <ipc/kbd.h>
+#include <async.h>
 
 #include <usb/usb.h>
@@ -253,4 +254,9 @@
 	usb_log_debug2("\n\nmods after: 0x%x\n", kbd_dev->mods);
 	usb_log_debug2("\nLock keys after: 0x%x\n\n", kbd_dev->lock_keys);
+	
+	if (key = KC_CAPS_LOCK || key == KC_NUM_LOCK || key == KC_SCROLL_LOCK) {
+		// do not send anything to the console, this is our business
+		return;
+	}
 	
 	if (type == KEY_PRESS && (kbd_dev->mods & KM_LCTRL) && key == KC_F1) {
@@ -453,5 +459,5 @@
 /*----------------------------------------------------------------------------*/
 
-static usbhid_kbd_t *usbhid_kbd_new()
+static usbhid_kbd_t *usbhid_kbd_new(void)
 {
 	usbhid_kbd_t *kbd_dev = 
@@ -475,4 +481,24 @@
 	
 	return kbd_dev;
+}
+
+/*----------------------------------------------------------------------------*/
+
+static void usbhid_kbd_free(usbhid_kbd_t **kbd_dev)
+{
+	if (kbd_dev == NULL || *kbd_dev == NULL) {
+		return;
+	}
+	
+	// hangup phone to the console
+	async_hangup((*kbd_dev)->console_phone);
+	
+	if ((*kbd_dev)->hid_dev != NULL) {
+		usbhid_dev_free(&(*kbd_dev)->hid_dev);
+		assert((*kbd_dev)->hid_dev == NULL);
+	}
+	
+	free(*kbd_dev);
+	*kbd_dev = NULL;
 }
 
@@ -623,4 +649,8 @@
 
 	usbhid_kbd_poll(kbd_dev);
+	
+	// at the end, properly destroy the KBD structure
+	usbhid_kbd_free(&kbd_dev);
+	assert(kbd_dev == NULL);
 
 	return EOK;
@@ -645,9 +675,9 @@
 	 * Initialize device (get and process descriptors, get address, etc.)
 	 */
-	usb_log_info("Initializing USB HID/KBD device...\n");
+	usb_log_info("Initializing USB/HID KBD device...\n");
 	
 	usbhid_kbd_t *kbd_dev = usbhid_kbd_new();
 	if (kbd_dev == NULL) {
-		usb_log_error("Error while creating USB HID/KBD device "
+		usb_log_error("Error while creating USB/HID KBD device "
 		    "structure.\n");
 		ddf_fun_destroy(kbd_fun);
@@ -658,10 +688,11 @@
 	
 	if (rc != EOK) {
-		usb_log_error("Failed to initialize USB HID/KBD device.\n");
+		usb_log_error("Failed to initialize USB/HID KBD device.\n");
 		ddf_fun_destroy(kbd_fun);
+		usbhid_kbd_free(&kbd_dev);
 		return rc;
 	}	
 	
-	usb_log_info("USB/KBD device structure initialized.\n");
+	usb_log_info("USB/HID KBD device structure initialized.\n");
 	
 	/*
@@ -675,4 +706,7 @@
 	if (rc != EOK) {
 		usb_log_error("Could not bind DDF function.\n");
+		// TODO: Can / should I destroy the DDF function?
+		ddf_fun_destroy(kbd_fun);
+		usbhid_kbd_free(&kbd_dev);
 		return rc;
 	}
@@ -682,4 +716,7 @@
 		usb_log_error("Could not add DDF function to class 'keyboard'"
 		    "\n");
+		// TODO: Can / should I destroy the DDF function?
+		ddf_fun_destroy(kbd_fun);
+		usbhid_kbd_free(&kbd_dev);
 		return rc;
 	}
@@ -690,5 +727,5 @@
 	fid_t fid = fibril_create(usbhid_kbd_fibril, kbd_dev);
 	if (fid == 0) {
-		usb_log_error("Failed to start fibril for HID device\n");
+		usb_log_error("Failed to start fibril for KBD device\n");
 		return ENOMEM;
 	}
Index: uspace/drv/usbhid/main.c
===================================================================
--- uspace/drv/usbhid/main.c	(revision 27270db1d62255b3767750c55bc91df14a0b8216)
+++ uspace/drv/usbhid/main.c	(revision 1c6c4092670c8cef1e8e1beaacf8cede220ab188)
@@ -40,19 +40,4 @@
 #include <errno.h>
 
-//#include <ipc/driver.h>
-//#include <ipc/kbd.h>
-//#include <io/keycode.h>
-//#include <io/console.h>
-//#include <str_error.h>
-
-//#include <usb/classes/classes.h>
-//#include <usb/classes/hid.h>
-//#include <usb/classes/hidparser.h>
-//#include <usb/request.h>
-//#include <usb/descriptor.h>
-//#include <io/console.h>
-//#include <stdint.h>
-//#include <usb/dp.h>
-
 #include "kbddev.h"
 
@@ -65,4 +50,6 @@
 static int usbhid_add_device(ddf_dev_t *dev)
 {
+	usb_log_debug("usbhid_add_device()\n");
+	
 	int rc = usbhid_kbd_try_add_device(dev);
 	
