[Core] Fixed a memory leak if "Open as submenu" is disabled.
[Core] Code style fixes.
[Core] Support tab cloning, closes #1644.
[Core] Code style fixes.