fix bugs in unparsing output