Refactored the common reporting code.