More basic logic: distinct, query extraction, game utilities