Fixed allocation problem.
Fixed memory leak.