error handling

added support for graceful shutdown after ctrl-c.  Also, fixed other
minor errors/exceptions