Typed static queries

I'm opening this PR so we can discuss the current state of the implementation.
Why are there separate MacroConnectionHandlerBase and MacroConnectionHandler classes, and why do we need an early initializer (rather than having a single class with a constructor parameter)?