Format autopurge code and add missing debug