Merging in changes on  original fork from ileitch