implemented language detection, other improvements