apply.c: pass struct apply_state to more functions