bug fixes to allow studies.py for more cases