Cleaned up JS_dismat in linalg.py