Fix bugs for background service bug.