Final Version

No memory leaks. All works.