Bug fixes and improvements related to previous changes