Fixing memory leak. Not yet done.