fix some issues with error handling