bitbeam library (ported from gridbeam library)