Slightly improved error reporting in some cases