Error handling and cache fix