I suspect that if you treated TVEs more like final objects and created new TVEs when you needed them instead of changing existing ones, you wouldn't have these hashCode problems. Conceptually a TVE should belong to one statement and it should not be changed to use an alias that comes from a parent statement.