Fixed freed memory accessing bug.

(Issue #32)