OS detection rewrite