refactor out some RTM agent stuff