Fixing memory leak in the ReOrient function

I tested this change with Eli and it fixed the memory leak.