Nicer code, fixed some bugs, and nicer output.