Github issues #260 and #240

This fixes the git hub issues #260 and #240