Clean up the court/council management code

This was hard to understand, so I’ve moved things around a little to make them clearer.