Fixed a couple of bugs and simplified output.