Complete lamsub, still needs debugging