fix some rev handling and memleak (bb#790)