Further decrease WQ lock contention.

Refs #5246
Avoid using dynamic_pointer_cast when possible.

Refs #5246
Allow common functions to be inlined.

Refs #5246