dynamic template clean up