Some keyboard recognition bug fixes