Miscellaneous fixes, tweaks, and additions (too many to list here, since I don't remember half of them). No doubt it also adds a bunch of fun new bugs...