Several small clean-ups and fixes, mainly to improve isolation.