updated most functions, introduced CG vars to the class