Refactor code so that messages go through engines