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.