C++ version included. Memory leaks fixed.