Some exception refactoring