fix popover problem and database leak problem