fixes realloc bug and suppresses while loop warnings