Fixed memory corruption

When allocating space for an array of ClassInstance's an array of
ClassType was allocated instead and implicitly cast from void* to
ClassInstance*. ClassType is smaller
than ClassInstance therefore the allocated array is too small and
writing the full array results in memory corruption.