Added better exception handler.