Robustness/consistency improvements

Hi there!  These are some changes I thought you might be interested in; the commit messages are fairly self-explanatory, so I'll shut up and let you read 'em. ;)