Factor and clean for testability
Use queues to manage dependencies