fixes from master and some little tweaks/fixes in tev code