Factored out bms.py