Split bw_Main into bw_Lib