include license file; some code refactoring