Adds better error handling to algorithm execution.