Clear selected model if it goes out of scope.  And fix a behind-by-one-update bug with selected model data.