Bug fixes.
constant rename.
Rebuilt writers to use factory.

Also did some other cleanups.