Initial implementation of the KSP algorithm.