Localised all static variables and made the CG routines more expressive