G was removed couple of places. Main rewritten.

Added a function to do calculations for a random system. It is, however,
not working. NaN pops up everywhere.