Fixed purge function.