Still refactoring: function values, mostly.

- Some problems have been introduced (I think something's gone wrong
  somehow with refcounting IR but can't track it down).