changed some array mallocs to callocs