Keyboard refactor, smal debug fix