speedup language detetion, coding style fixes