Several changes to bb_main