Small corrections
Code refactoring

- Bug fixed where contracts ended with 'depart_child' as ending
  reason were not correctly updated in GP.
- Code refactoring
Code refactor