Fix output bug, direct to stdout
Fix printing bug, clarify variables