Simpler context closing
More refactoring