Rebased #239 off master