Some fixes for the memory leak, but introduced a serious bug (doesn't work atm). Will continue tomorrow to fix this last issue, and it should work well.