remove unnecessary insertUnique function
refactoring of _createMenuHelper.

i do not understand the meaning of this code fully, but it should still be
syntactically identic.
remove unused code and blank lines.