WIP: Refactor certificate agent and queue

Details to follow...
Should this be put or post?