bml: also extract the bmlw cleanup code