Issue #5704: Fix bugs