Wikimedia improvements

Here are some small changes that should probably get ported directly to master (especially 3141194 and 228493b)