Assorted bugfixes.