memory freeing corrected.