fix context menu error introduced in #b4f43c5200 and code cleanups