Fix problem when using Jammit Optimizer.

We ran into a problem using this when bundled up with JAMMIT.  It turns out that the instanceof check would not work.  Recoding the functions to be contained in the containing scope, solved this problem.