big refactoring, tests and license change