Bug fixes and improved functionality for SUM