addition al bug fixes for writer.