Changed license to MIT and some refactoring