Added tolerance support for submenus positioned above and below the main menu.