Start catching out of memory errors
Check malloc return codes
Merge pull request #2 from e9925248/master

Start catching out of memory errors