Replace new tab func with context menu version

Also improved code in db calls to stored procedures so that similar code
is put in one common function.