Improved context menu handling