HAndle context managers correctly.