Bug contract workflow

Fixes the bug that prevented to reach terminated state of a compassion contract. Some hooks added for adding code on contract activation.