Added custom calloc; checks agains NULL pointer