Refactored. Added more fields to generated output.