Merge into upstream master

I've merged both changes from @kylefarris and me.