Rearranged functions in spi.c