full refactoring of the Prolog side API