Diverse bug fixes and enhancements