Fixed three possible buffer overflows