Bug fixes and enchancements