Allow deduplication of actions in run and finalize phases

I would here go for extracting the assigning outside of the condition, also, there is some repeated code that could be deduplicated :)