Fix bugs caused by earlier refactoring, fix #1655