Turn everything into generic functions.

This opens up the path for multiple backends.