Rotation and precession of cometary nuclei