Fixed segfault for terminated always and on periodic blocks