more refactoring and now shared code is actually starting to work.

cleaned up xml/json.
fixed json output.  made xml output even better.