A few bug fixes and minor enhancements