Split into classes, mostly working :-)