Fixed some memory issues.
Fixed some memory leak issues.
Some corrections that should be with last commit.