added accelerometer api + some refactoring.

NEXT: write better accelerometer logic.