Fix of issues #2851 and #3064 (1-3-stable branch)