Fix the bug part of Trac #1930