Rewrite partly working.
One more DRY to tackle, more testing.