Removed mallocs in the recursive part.