Major fixes and improvements