Move plot add to separate js and fix issues

fixes #1717 on github
fixes #1375 on github
fixes #1027 on github
Update plot_detail header when plot/tree changes

fixes #1715 on github
fixes #861 on github
improves #1719 on github, but does not fix it.