Several bug-fixes and adaptations for new releases

- Prolog DM compiles with recent SWI release again
- Bugfixes for stress test
- Beautified code