Completes refactor and tests