Worked out final bugs in output.