fixed some memory leak stuff