Molecular dynamics of initial events in the thermal degradation of polymers