Major rework (I know - again). Class based API and metaclasses and stuff