Reorganized ED main code to be more readable, and added accelerometer initialization.