On the evolution of sex and its consequences