fixed some leaks and analyzer warnings