Some refactoring as initial attempt to fix [f214b8ad5b]. Not finished/tested yet.
Make "menu" a normal command, initialized like any other Tk command.
merge trunk
Store menu option tables in Thread storage in stead of allocated storage. This makes "menu" a normal command without needing special initialization tricks.