Merged from Upstream and added earlier changes again