WIP: Refactor certificate agent and queue

Details to follow...
That was the existing logic.

Makes sense to update.