added functions to cgUtils, cleaned up code and docstrings in foptics and transformutils