Realloc is causing some memory errors.