Forward-port 0.5 r10276 to trunk, and add a few more cleanups.

git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10277 c06c8d41-db1a-0410-9941-cceddc491573

Created by  dolorous  on July 18, 2009
PUO3U5MM6BGXC7BO4PKI77KWEOAWOFF3ZYSVDZJBG2XO7JT3II3AC
Change contents