minor cleanup
improved stdin/stdout support