Improvements to output and cleaned some code.