Added typecast to mallocs