Moved read_length_callback callsite.  Reallocated buffer if read_length_callback returns larger than current buffer size.  Addressed other review comments.