Refactoring of exception handling.