Code refactoring & "failure reason" handling