wip-442: Token aware writes

This probably doesn't matter here, but generally rounding capacity up to power of 2 and using logical & is a good practice when doing cyclic buffers. Logical operations and shifts are way faster than remainder computation.