Bug fixes in q-run.py