lower_dw: huge refactoring, allow custom lowering funcs, fix endianess problems