WIP: Refactor certificate agent and queue

Details to follow...


Done; coming in next push.