Fixed memory allocation bug.