various attempts at leak fixes (#50)
fixed conflicts