optimize type of interim G and almost V

V (values) is currently int/long only, but -1 should be casted to MAX instead,
and we would need to store other types also