Context3d fixes

Most of the changed lines are due to that last commit, so all that got changed is the whitespace. I'm considering reverting that one just to make the diff less dramatic. The others are way more important, after all.