partially patched ksv code