Some more work, mostly old code, I'll continue later