Added docstrings and did some code cleanup for cs_util.py