fix #573, fix #361