fixed misc memory leaks