Make tooltip more robust

Correct handling of popup now.