fix #1416, #1437 and a possible fix for #118