Fix free-variable calculations for types