Extract the model relationship code into its own separate function and
extend it so that we can fold in the relationships from modules that are
installed but not yet active.
Disable output buffering (recommended) and activate the gallery module
after install.