Moved image count saving to onPause