Fix use_expires and minor refactoring.