Further improvement to prerender and cleanup