refine context clean up