fixed other inconsisencies, but with realloc is back, needs to be fixed