improvements to getsortedspikes