Fix device id decoding (fix #610)