Code refactor for the executor module, to be committed in next commit.