various bugfixes and improvements found during the push to fix wiki.py