refactor - better platform detection, etc