Add a check to ensure realloc works properly.  Moved default initializations to the proper place.