a complete Gauss rewrite and ~20 times speedup