On the origin of comets