Fixing buffering to be more generic