Added fixes suggested in pr #3874.