Several minor bug fixes.