Adding some Prolog stuff I still don't quite understand.