pull request to pick up changes from my master branch to yours.

i think my previous pull requests were wrong. this should hopefully be correct.