Moved all the code into the background page.