forward-port 17091 and 17104 from 0.8.6