Extract some shared functionality to a new super class.

I thought that these two were going to be different enough that a shared super wouldn't make sense,
but there ended up being rather a lot of copied code, so here we are.
Function.length against varags strikes again.