Language detection rework