beginning refactoring and normalization of popover building code