Improved OS detection