Fix buffer overflows