Implement foreground state updating

Service will stop when app is backgrounded now.
Also some code cleanup.
Update README