serialize context instead of trying to recreate it

**do not review yet**