rewrote lsx in python.