weak refs and other fixes