Add some more safety to the contextFactory.