Extract behavior.

Extract behavior from the backend and add type signatures for all of
the backend methods.