factorize bb_init_magic()