ENH: Some refactoring and optimisation in sprasefuncs.pyx