Miscellaneous bug fixes.