More error checking on allocations

- changed remainder of allocations to follow same 1.5x patters
- do not leak memory when realloc() fails
- added error handling in case allocations fail