fix ThreadLocal access, introduce BufferAllocator