Origins of the machinery of recombination and sex