Supercedes #1118

updated #1118 against dev