First pass at #540
Merge pull request #1150 from kuyan/patch-1

First pass at #540