Background tasks

The core of the background tasks code