Error handling improvements