some bug fixes in new writer