updates to tls

minor changes to tls, tls.distance, and sgd to improve performance