Refactors functions, adds licence file