Modification of polymers under heterogeneous conditions