Connected councils API and cleaned up code