BBVS: Move some code out of bbvs.cpp