Fix for #1154, #1857, #1959, #1978