fix memory leaks with spimodule