Fix KHD id decoding (fix #800)