Rebased work from pull request #144 to current master