platform specific stuff & refactoring