Manual merge of fixes and improvements