fix some more leaks and stuff