Rebuilt the menu generator to be more flexible and valid