Compounds containing epoxy groups or precursors thereof