Move much initialization to reset() function so that the writing objects can be reused.