Bug fix, removed free(buf). Formatting.