Moved some mirror support code into its own module