Additional changes to cope with Beta 6 (which apparently doesn't like nested fns)

NOTE: You may need to clean your build folder for this to build correctly.