Split leader loop out into its own function.
Add a map to store parsed continuous queries.