Fix buffer overruns