NOJIRA: still trying to resolve merge conflicts. This is an earlier version of cswaUtils.py