fix template errors
optimize menu iterators
Merge branch 'master' into 2.5