more efficient buffer reallocation and error handling