Major structural and style changes

Modified some variable names, divided functions into appropriate files.
Changed autonomous mode resolution logic.