big update, with all changes from slate

Tbh, the code before this should be ignored, as it was written about
6 months before this checkin.

This is pretty much a re-write of the whole framework,
within Slate, and now copied over here.