Ensure persistent classes are saved with correct duration.

Close #3259. Previously the persistence counter was converted erroneously
to bool in AddAllClasses, making all persistent classes have a ttl of
1 minute.
(cherry picked from commit 70611ac39674e355b874cd06c926f388f2d5091b)