this API isn't very nice, but it's pretty much the same as the original, and at least this can be _kinda_ unit-tested...