bug fixes and performance enhancements