Fixes from itvm integration

Mostly itvm related changes. Mostly stuff to make the code more pythonic (iterate over the lists themselves instead of indexes for instance).