cleanup code and adding license headers