Cleanup OnBeforeContextMenu code