correcting a few bugs, and prettifying printing