Added uncaught exception handler

Improved error messaging