Fixed a few bugs which were discovered after testing on the real hardware.
Fixed bug that caused automation_mode to be ignored (and always on).