Finish, refactor, add docs, add tests