Moved prepare code to common handler

Added ability to change repo preferences file.