Bugfixes after adding datalog