improve context management
Merge remote-tracking branch 'sonata-project/master'