Fixed Windows detection
Added catches for errors