Fix #457 and fix #557