Error handling and fixes