Bug fixes for bug #642
Merge pull request #644 from linas/buggy

Bug fixes for bug #642