Final prolog functions.