Folded in code changes from Ben needed for new controller firmware - added TC_STOPPING state, and big changes to exception handling.