Adding license information + some fixes and refactoring