Various fixes and enhancements