Fixes for Issue 9

This pull requests contains the fixes for the problems as described in issue #9