New version with various fixes and changes