Licensing implementation and some other small refactorings