better cmdline arg handling, and wrinting