Remove debug and fix memory realloc