Transformation from AST to terms

Changed the parser to only accept sorts as types type.
Fix some wrong use of name/ref in the TLoc' type
Remove the name nvironment from the state monad, it was deeply stupid.