Cleanup code and update docs in bst.py.