Fixes to controller.py