Improve the way a two-pane layout is detected
Fix several issues with the menu items and improve the threading interface