Add comment
Upgrade Stats when the app is moved from Background to Foreground. Also improved the code that handles application lifecycle events.