Fix buffer size bug