add console listener and do some cleanup
Merge pull request #45 from dbu/console

add console listener and do some cleanup