Miscellaneous fixes

These are a few miscellaneous kernel and javascript driver changes that came out of working with VWF on other projects. They are mostly independent of each other and the preceding changes. But there is one merge conflict, so they're stacked on top of branch/find-trees so that we don't risk a merge error later.

@eric79 please review.

@davideaster I'll respond by paragraph.  :smile: 

1. Ah, I see ... I hadn't realized that you were determining if the caller was using the two or three-parameter version of this function.  Could you add a comment to that effect?
2. Hmm ... I don't feel too strongly about this one.  If you would like to keep it in this function, I'm okay with that.
3. Your call.  I am a little alarmed at how much identical code there is in VWF.  This doesn't feel good because it's a step in the wrong direction, however small of a step it might be.