Update upstream: bug fixes and enhancements