add osx support and refactor structure