Add license and refactoring