more bugfixes for bug #296

The first fix was incomplete.
Merge pull request #303 from linas/bugfix

more bugfixes for bug #296