refactor context initialization spi