please, use Ptr&lt;&gt; instead of plain pointers. The current code has memory leaks.