Refactor rotator code