Context change

This consists of the first two commits from #1269, rebased and slightly modified.
same comment as above