cleaned up many non SWI-Prolog bits. Still needs output/3 defined