dev ver2, rewrote G and L funcs.

many todos, very buggy.