Fix loss of context

Closes #8