Improved language detection