Some SWI prolog fixes