Fix a segmentation fault.

Child modifications should come before possible deletion of the child...

Error found by Haiyan when running scram.