Added ability to hook in listener from the command line.
Command-line code now only runs if interpreter is run as main module. Fixed some logging issues and specified module exports for usage of the code as a module in some other code.