added appropriate buffer sizing for multithreadedness