Fixed buffer size bugs in io.c.