Added some initialization for a few variables to fix the issue of integer overflow when calculating the amount of memory to allocate