Fix issue with buffer being undersized