[fix] adds code that sets proper length of buffers