rework BIP moreorless from scratch