factor out formatObjects
Factor out outputObjects
Merge branch 'refactoring_codecleanup'