Fix namespacing issue in mode generator.

[ fix #2886 ]