fix #2170, #2135, #2121 and #1957