Added checks for NULL returns by calloc

It seems like there is a few places where ```calloc()``` is called and then we simply cross our fingers and hope that the user got memory available. Now it prints an error message and exits with code ```1```, if we get a ```NULL``` pointer.