Woohoo. Fixed the problem with passing arrays into functions. All hail the nwglobal module