Fixed bug with buffer length