Improve error handling at all stages of execution