lib: large cleanup; fix spin difusion