Moved all the writers to their own module.

Other refactoring changes.