Code refactoring to normalize Prolog output (requires an update of the prolog rules)