Bug fixes and minor enhancements