It seems to me that the memory leak is fixed. Other minor changes