Fix memory problems.
Fix the issue with deallocation of static data.