Refactor #5580: Fix some issues