merged fix for #2572 and #2574 from snapshot