Issue #4589: Fix bugs