Fix to #752, #645 and #310 (regressed)