fix template errors
optimize menu iterators