I am baffled by the behavior of the code below. There are two problems; I am not sure whether they are related in some strange way.
The first problem is the more impo