I always use P mode with my S30 (unless I want AV mode) and that way I have one focus "box" to to be concerned with. I think that is easiest for me. I also use only iso 50 so I have that constraint.
Also, I know that I move the camera when I press the shutter button so some pics are blurred because I have a problem with that.
Sometimes, I don't think the camera is focusing where I think it is focusing. Like with your example, maybe the camera focused on the wall. I should do a test with some cards placed close together to see if the camera focuses the way that I think it does, maybe it works a little differently than I imagine. Maybe a corner of the focus box is where it is happening and not in the center of the box.
When I turn off the flash and use available light only, I expect to have some blur but I have practiced doing that and think that my pictures with the flash disabled are getting better. Of course, I usually adjust white balance with indoor shots.
I shot some flowers recently with no flash and only the available indoor lighting and a lot of the pics were fairly well focused. Here is the link to that gallery if you would like something to compare with. Bear in mind that they did require post processing, the indoor shots didn't come out of the camera like that but they are true to life.
http://www.pbase.com/steveandbecky/dahlia_show
I understand what you mean by random.
Just my thoughts on focusing.
-Steve