Various fixes and minor enhancements