More robust median logic after Wikimedia tests.