Fix several errors in RTF text generation