Refactor statistics task api.