Merge pull request #41 from colincoghill/master

Series of bugfixes since 3.9.2 release