Added support for linux and mac + some refactoring
Heavy refactoring