Changing some memory allocations (alloca by malloc) to avoid critical errors