Proposed changes to fix issue #32

Here is an updated pull request with a proper history.