Refactored cli.js
Merged from upstream.
Removed log.
Added safety logic to prevent undefined access.
PR cleanup.
Merge pull request #14 from arb/code-cleanup

Code cleanup