Did some refactoring and OS checking.