functionally done. trimmed down, added command line and stdin parsers.