Factor out behavioral code from the repl component.