Refactoring codes

bsmonitor, bsnext, etc.