Fix issue where popover is undefined

Removed unnecessary code as well.