Added ability to read from stdin and fixed command-line processing