Fixed encoding issues for good, improved cid conversion