Extracted queue handling into its own module. Seperate active and purge queue.