Errors processing, small refactoring