Slightly improved accelerometer code