The molecular composition of comets and its interrelation with other small bodies of the Solar System