Merge pull request #32 (with additional fixes)