rewrite repository factories