Tidied up, started on OS detection