fixes memory leak regarding context as member