removed redundant functions (update_fn_get_update_fun_lhs and update_fn_get_lhs are the same, same for rhs)
create new function to group index ranges based on pr_indices. Reworked pr_indices to avoid code duplication. (I noticed there is another copy of pr_indices in an abstract type in the preamble... I haven't touched that one)
Added size checks to SX and ZX function to avoid "extending" into a smaller size
See individual commits: