fixed several bugs for bts.py