Code cleanup
Move most of the work to a background job.