very big progress. Does not compile but worth saving.
nearly works. missing implicits for ordering