Changed the call to malloc to calloc when initializing arrays