following #814 from mainline