rearrange combinator order: put dependencies before the code that uses them; also fix type comments and flipped variable names