memory management works.

now need to find next bug.