Changed the structure of the menu loops

* Now, the buttons' actions are called from within the loop instead of
ending the loop before calling them.
* Button callbacks can now have return values in the form of a kind of
dictionary.