Rework error handling