Most of the hard work for adding lvalues.

There are still a few small TODOs that will make error handling nicer,
and so on, but all the tricky stuff is done.