check in miroslav's long-lost bitbuffer optimizations