Fixed selectable buttons in popover. Various other code cleanup