Added a kernel-to-distance function, moved some more looping code into numpy idiomatic code, cleaned up comments.
Added some comments.