changes to attempt to avoid memory leaks (and to support updates in special cases