fix some more memory problems