Fixes issues mentioned by Brent in pull request #1.