Miscellaneous improvements and bug fixes.