Implemented most of the methods necessary for background service.