Adapted from beliefstate to semrec
Deleted old unused code
Reintroduced prolog logging (plus switch), removed old code