Slightly improved error handling and messaging