Compare against nil not 0.
Move ffi.new to upvalues.
Added comment about keeping references to pointers.