Deformations of zero-dimensional schemes and applications