I changed my mind again. Back into lib.

Revert "Move things from lib/ back into backend/ to unbreak the tests. 'Twas a"

This reverts commit b266c408b2537900b4918fea6070e9e4ea6126ad.