We obtain an improved version of the area theorem for not necessarily differentiable horizons which, in conjunction with a recent result on the completeness of generators, allows us to prove that under the null energy condition every compactly generated Cauchy horizon is smooth and compact. We explore the consequences of this result for time machines, topology change, black holes and cosmic censorship. For instance, it is shown that compact Cauchy horizons cannot form in a non-empty spacetime which satisfies the stable dominant energy condition wherever there is some source content.