Some fixes for exceptions