Many fixes and improvements.