Minor cleanup and bug fixes.