Refactor
The ensure is deleteing to early; clean up tmp periodically instead