decrease duplication of fresh* function definitions

This commit extracts out freshTermName and freshTypeName to the top-level
with implicit fresh name creator argument. This will let to refactor out
more methods out of tree builder into treegen that are dependent on fresh
name generator. We also save quite a bit of boilerplate by not having to
redefined fresh functions all over the place.