Fixed IO bugs for plugins, and added buffer to malloc.