Added better support for exceptions