These three links provided lots of insightful information. I used that to update my code. I still am not positive everything is working right. I wrote a little visualization routine that will hook up the serial output of the accelerometer and visualize the data coming back plus the orientation. An example is shown below.
This shows that the values are close to one when the dominant axis is pointed down (or -1 if oriented in the other direction). However, the values are not quite zero when sitting still. Clearly a better calibration routine is needed to correct for these slight errors. In these plots, red is the x axis, green is the y access and blue is the z axis. The noise in the output can also been seen in the values along the bottom. However, at least I am convinced that the numbers are in the right ballpark. However, until I have formulated a dynamics model the scaling and calibration is not as high a priority.
I will next switch and repeat the process for a magnetometer. Hopefully this will be fairly easy as most of the work in dealing with accelerometer was setting up infrastructure. I also ordered a small robot kit. When that arrives I will start playing around with wheel encoders and simple navigation using dead reckoning.