Fix writer bugs.