Big restructure. Be more middleware like.

Lot's of failing tests now.
Use new api.