some refactoring and finishing of the accelerometer code