Refactor repo code.

Decoupled from recipe and parameterized.