Create a background script

Start here:

Especially take note of the memory leak opportunities and persistent dictionary solutions.