manual incorporation of changes from pulls/382