Random bug fixes for XML writer and Format Type