Move the main queue handling and the clock to separate modules.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>