Several bug fixes and updates