Fixed massive  memory leak caused by recreating data buffers.
Code cleanup.