Refinement and error handling