Fixes for console

* Check for __name__ == '__main__'
* Log out user when shell terminates
* Prevent inclusion of empty module names
* Catch sys.exit() and other exceptions that terminate shell
* More descriptive error messages when imports fail