Refactoring, protocol update, tests, documentation