Incorporated some changes from from @bmatson via issue #230