refactor flyout into popover

(minor changes though, mostly compatible