Finally fixed annoying freed memory bug.