Some fixes for better error recognition