refactor richtext to mirc code conversion to fix some bugs