Bug fixes and enhancements