bunch of fixes to OS detect logic