fixes for saving the last count when the app is closed