Fixed formatting and output.

Needs debug mode and further testing.