LW wrapper code, most of sw wrapper