Fixed code that, according to clang, were open to buffer overflows