Moved prepare code to common handler

Added ability to change repo preferences file.
Why are we removing this (is this duplicated code)?