Bug fix and enhancements