Added maven configuration, unit tests, some refactorings