refactor, add license, add a few functions