bugfixes:
    - Attempt to avoid race condition based on incorrect buffer size assumptions